Return hashes with getlatestblock

This commit is contained in:
Aditya Kulkarni 2021-07-26 13:11:02 -07:00
parent 7f81fcbf78
commit 1b485256a3
2 changed files with 8 additions and 4 deletions

View File

@ -80,6 +80,7 @@ type (
Chain string Chain string
Upgrades map[string]Upgradeinfo Upgrades map[string]Upgradeinfo
Blocks int Blocks int
BestBlockHash string
Consensus ConsensusInfo Consensus ConsensusInfo
EstimatedHeight int EstimatedHeight int
} }

View File

@ -146,13 +146,16 @@ func (s *lwdStreamer) GetLatestBlock(ctx context.Context, placeholder *walletrpc
var getblockchaininfoReply common.ZcashdRpcReplyGetblockchaininfo var getblockchaininfoReply common.ZcashdRpcReplyGetblockchaininfo
err := json.Unmarshal(result, &getblockchaininfoReply) err := json.Unmarshal(result, &getblockchaininfoReply)
if err != nil { if err != nil {
return nil, rpcErr return nil, err
}
hash, err := hex.DecodeString(getblockchaininfoReply.BestBlockHash)
if err != nil {
return nil, err
} }
common.Metrics.LatestBlockCounter.Inc() common.Metrics.LatestBlockCounter.Inc()
return &walletrpc.BlockID{Height: uint64(getblockchaininfoReply.Blocks), Hash: parser.Reverse(hash)}, nil
// TODO: also return block hashes here
return &walletrpc.BlockID{Height: uint64(getblockchaininfoReply.Blocks)}, nil
} }
// GetTaddressTxids is a streaming RPC that returns transaction IDs that have // GetTaddressTxids is a streaming RPC that returns transaction IDs that have