Skip to content

Commit

Permalink
subscriber: fix off-by-one in awaitHeight()
Browse files Browse the repository at this point in the history
Block count is literally a block counter, while block height is the height
written in the block. For block zero the height is zero while we have one block
in the chain and therefore the count is one. Persistent store operates with
heights, therefore comparison should be adjusted by one.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
  • Loading branch information
roman-khimov committed Aug 5, 2023
1 parent cd628f7 commit 08e9e29
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/morph/subscriber/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func awaitHeight(cli *client.Client, startFrom uint32) error {
return fmt.Errorf("could not get block height: %w", err)
}

if height < startFrom {
if height < startFrom+1 {
return fmt.Errorf("RPC block counter %d didn't reach expected height %d", height, startFrom)
}

Expand Down

0 comments on commit 08e9e29

Please sign in to comment.