Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcoin relayer improvements for rollkit #15

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding a method to get the latest height
  • Loading branch information
Ferret-san committed Mar 5, 2023
commit 52566776fbc57690667c67b1fc9e066b10283deb
2 changes: 1 addition & 1 deletion generate_block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ while :
do
echo "Generate a new block `date '+%d/%m/%Y %H:%M:%S'`"
bitcoin-core.cli -regtest -rpcport=18332 -rpcuser=rpcuser -rpcpassword=rpcpass generatetoaddress 1 $address
sleep 5
sleep 1
done
8 changes: 8 additions & 0 deletions relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ func (r Relayer) ReadTransaction(hash *chainhash.Hash) ([]byte, error) {
return nil, nil
}

func (r Relayer) LatestHeight() (int64, error) {
latest, err := r.client.GetBlockCount()
if err != nil {
return -1, err
}
return latest, nil
}

func (r Relayer) Read(height uint64) ([][]byte, error) {
hash, err := r.client.GetBlockHash(int64(height))
if err != nil {
Expand Down