Skip to content

Commit

Permalink
Remove cid-based shortcut
Browse files Browse the repository at this point in the history
This optimization should be handled by the index, not the scan code.  It also produces undesirable errors which have been corrected in this commit.
  • Loading branch information
AndrewSisley committed Oct 26, 2022
1 parent 064023a commit af48e5d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
16 changes: 0 additions & 16 deletions planner/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,6 @@ func (n *dagScanNode) Next() (bool, error) {
if len(n.queuedCids) > 0 {
currentCid = n.queuedCids[0]
n.queuedCids = n.queuedCids[1:(len(n.queuedCids))]
} else if n.parsed.Cid.HasValue() && !n.parsed.DocKey.HasValue() {
if n.visitedNodes[n.parsed.Cid.Value()] {
// If the requested cid has been visited, we are done and should return false
return false, nil
}

cid, err := cid.Decode(n.parsed.Cid.Value())
if err != nil {
return false, err
}

if hasCid, err := store.Has(n.p.ctx, cid); !hasCid || err != nil {
return false, err
}

currentCid = &cid
} else {
cid, err := n.fetcher.FetchNext()
if err != nil || cid == nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/query/commits/with_cid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestQueryCommitsWithInvalidCid(t *testing.T) {
}`,
},
},
ExpectedError: "encoding/hex: invalid byte:",
Results: []map[string]any{},
}

executeTestCase(t, test)
Expand All @@ -128,7 +128,7 @@ func TestQueryCommitsWithInvalidShortCid(t *testing.T) {
}`,
},
},
ExpectedError: "length greater than remaining number of bytes in buffer",
Results: []map[string]any{},
}

executeTestCase(t, test)
Expand Down

0 comments on commit af48e5d

Please sign in to comment.