Skip to content

Commit

Permalink
Repostore crash debug (#521)
Browse files Browse the repository at this point in the history
* repostore listBlocks reads too much data

* Add assert to make sure data is not queried
  • Loading branch information
benbierens authored Aug 22, 2023
1 parent f459a2c commit 238771e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion codex/stores/repostore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ method listBlocks*(
of BlockType.Block: CodexBlocksKey
of BlockType.Both: CodexRepoKey

without queryIter =? (await self.repoDs.query(Query.init(key))), err:
let query = Query.init(key, value=false)
without queryIter =? (await self.repoDs.query(query)), err:
trace "Error querying cids in repo", blockType, err = err.msg
return failure(err)

Expand All @@ -281,6 +282,7 @@ method listBlocks*(
iter.finished = queryIter.finished
if not queryIter.finished:
if pair =? (await queryIter.next()) and cid =? pair.key:
doAssert pair.data.len == 0
trace "Retrieved record from repo", cid
return Cid.init(cid.value).option

Expand Down

0 comments on commit 238771e

Please sign in to comment.