Skip to content

Commit

Permalink
add GetLatestTreeState() grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry Ruane committed Jan 2, 2021
1 parent 0e0cdcc commit 8868c4d
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 47 deletions.
7 changes: 7 additions & 0 deletions docs/rtd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,13 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactTxStreamer">CompactTxStreamer</h3>
The block can be specified by either height or hash.</p></td>
</tr>

<tr>
<td>GetLatestTreeState</td>
<td><a href="#cash.z.wallet.sdk.rpc.Empty">Empty</a></td>
<td><a href="#cash.z.wallet.sdk.rpc.TreeState">TreeState</a></td>
<td><p></p></td>
</tr>

<tr>
<td>GetAddressUtxos</td>
<td><a href="#cash.z.wallet.sdk.rpc.GetAddressUtxosArg">GetAddressUtxosArg</a></td>
Expand Down
9 changes: 9 additions & 0 deletions frontend/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ func (s *lwdStreamer) GetTreeState(ctx context.Context, id *walletrpc.BlockID) (
}, nil
}

func (s *lwdStreamer) GetLatestTreeState(ctx context.Context, in *walletrpc.Empty) (*walletrpc.TreeState, error) {
latestHeight := s.cache.GetLatestHeight()

if latestHeight == -1 {
return nil, errors.New("Cache is empty. Server is probably not yet ready")
}
return s.GetTreeState(ctx, &walletrpc.BlockID{Height: uint64(latestHeight)})
}

// GetTransaction returns the raw transaction bytes that are returned
// by the zcashd 'getrawtransaction' RPC.
func (s *lwdStreamer) GetTransaction(ctx context.Context, txf *walletrpc.TxFilter) (*walletrpc.RawTransaction, error) {
Expand Down
138 changes: 91 additions & 47 deletions walletrpc/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions walletrpc/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ service CompactTxStreamer {
// values also (even though they can be obtained using GetBlock).
// The block can be specified by either height or hash.
rpc GetTreeState(BlockID) returns (TreeState) {}
rpc GetLatestTreeState(Empty) returns (TreeState) {}

rpc GetAddressUtxos(GetAddressUtxosArg) returns (GetAddressUtxosReplyList) {}
rpc GetAddressUtxosStream(GetAddressUtxosArg) returns (stream GetAddressUtxosReply) {}
Expand Down

0 comments on commit 8868c4d

Please sign in to comment.