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 Jun 24, 2022
1 parent de700e3 commit 72c9fc1
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 49 deletions.
7 changes: 7 additions & 0 deletions docs/rtd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,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 @@ -232,6 +232,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
106 changes: 57 additions & 49 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 @@ -175,6 +175,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
36 changes: 36 additions & 0 deletions walletrpc/service_grpc.pb.go

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

0 comments on commit 72c9fc1

Please sign in to comment.