Skip to content

Commit b805382

Browse files
str4dLarryRuane
authored andcommitted
Only pass limit argument to z_getsubtreesbyindex if maxEntries > 0
We also remove the `i < maxEntries` bound on returned results, as the `limit` parameter already causes `zcashd` to bound its returned entries. Closes #444.
1 parent ab90099 commit b805382

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

frontend/service.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,14 +689,16 @@ func (s *lwdStreamer) GetSubtreeRoots(arg *walletrpc.GetSubtreeRootsArg, resp wa
689689
if err != nil {
690690
return errors.New("bad startIndex")
691691
}
692-
maxEntriesJSON, err := json.Marshal(arg.MaxEntries)
693-
if err != nil {
694-
return errors.New("bad maxEntries")
695-
}
696692
params := []json.RawMessage{
697693
protocol,
698694
startIndexJSON,
699-
maxEntriesJSON,
695+
}
696+
if arg.MaxEntries > 0 {
697+
maxEntriesJSON, err := json.Marshal(arg.MaxEntries)
698+
if err != nil {
699+
return errors.New("bad maxEntries")
700+
}
701+
params = append(params, maxEntriesJSON)
700702
}
701703
result, rpcErr := common.RawRequest("z_getsubtreesbyindex", params)
702704

@@ -708,7 +710,7 @@ func (s *lwdStreamer) GetSubtreeRoots(arg *walletrpc.GetSubtreeRootsArg, resp wa
708710
if err != nil {
709711
return err
710712
}
711-
for i := 0; i < int(arg.MaxEntries) && i < len(reply.Subtrees); i++ {
713+
for i := 0; i < len(reply.Subtrees); i++ {
712714
subtree := reply.Subtrees[i]
713715
block, err := common.GetBlock(s.cache, subtree.End_height)
714716
if block == nil {

0 commit comments

Comments
 (0)