Skip to content

Commit

Permalink
fix compare-blocks tool command
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Jan 9, 2024
1 parent 3f1edef commit bffc42b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ If you were at `firehose-core` version `1.0.0` and are bumping to `1.1.0`, you s

## Unreleased

* Fix 'tools compare-blocks' that would fail on new format
* Fix substreams to correctly delete `.partial` files when serving a request that is not on a boundary

## v1.0.0
Expand Down
19 changes: 17 additions & 2 deletions cmd/tools/compare/tools_compare_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func runCompareBlocksE[B firecore.Block](chain *firecore.Chain[B]) firecore.Comm
stopBlock,
sanitizer,
&warnAboutExtraBlocks,
chain.BlockFactory,
)
if err != nil {
bundleErrLock.Lock()
Expand All @@ -154,7 +155,15 @@ func runCompareBlocksE[B firecore.Block](chain *firecore.Chain[B]) firecore.Comm
wg.Add(1)
go func() {
defer wg.Done()
_, currentBlocks, err = readBundle(ctx, filename, storeCurrent, uint64(fileStartBlock), stopBlock, sanitizer, &warnAboutExtraBlocks)
_, currentBlocks, err = readBundle(ctx,
filename,
storeCurrent,
uint64(fileStartBlock),
stopBlock,
sanitizer,
&warnAboutExtraBlocks,
chain.BlockFactory,
)
if err != nil {
bundleErrLock.Lock()
bundleReadErr = multierr.Append(bundleReadErr, err)
Expand Down Expand Up @@ -209,6 +218,7 @@ func readBundle[B firecore.Block](
stopBlock uint64,
sanitizer firecore.SanitizeBlockForCompareFunc[B],
warnAboutExtraBlocks *sync.Once,
blockFactory func() firecore.Block,
) ([]string, map[string]B, error) {
fileReader, err := store.OpenObject(ctx, filename)
if err != nil {
Expand Down Expand Up @@ -240,7 +250,12 @@ func readBundle[B firecore.Block](
continue
}

curBlockPB := sanitizer(any(curBlock).(B))
b := blockFactory()
if err = curBlock.Payload.UnmarshalTo(b); err != nil {
break
}

curBlockPB := sanitizer(b.(B))
blockHashes = append(blockHashes, curBlock.Id)
blocksMap[curBlock.Id] = curBlockPB
}
Expand Down

0 comments on commit bffc42b

Please sign in to comment.