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

Return hashes from getlatestblock #361

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ lwd-api.html
*.orig
__debug_bin
.vscode
frontend/unittestcache/
3 changes: 3 additions & 0 deletions frontend/frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func TestGetLatestBlock(t *testing.T) {
if blockID.Height != 380640 {
t.Fatal("unexpected blockID.height")
}
if string(blockID.Hash) != string(block.Hash) {
t.Fatal("unexpected blockID.hash")
}
step = 0
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func checkTaddress(taddr string) error {
// GetLatestBlock returns the height of the best chain, according to zcashd.
func (s *lwdStreamer) GetLatestBlock(ctx context.Context, placeholder *walletrpc.ChainSpec) (*walletrpc.BlockID, error) {
latestBlock := s.cache.GetLatestHeight()
latestHash := s.cache.GetLatestHash()

if latestBlock == -1 {
return nil, errors.New("Cache is empty. Server is probably not yet ready")
}

// TODO: also return block hashes here
return &walletrpc.BlockID{Height: uint64(latestBlock)}, nil
return &walletrpc.BlockID{Height: uint64(latestBlock), Hash: latestHash}, nil
}

// GetTaddressTxids is a streaming RPC that returns transaction IDs that have
Expand Down