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

add GetLatestTreeState() grpc #323

Merged
merged 1 commit into from
Jun 24, 2022
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
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.