Skip to content

Commit

Permalink
fix batch off by one (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu authored Jun 6, 2023
1 parent c40a2ce commit 38438d8
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions cmd/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,12 @@ var MonitorCmd = &cobra.Command{
ms.ChainID = cs.ChainID
ms.PeerCount = cs.PeerCount
ms.GasPrice = cs.GasPrice
batchSize := new(big.Int).SetUint64(batchSize)
batchSize := new(big.Int).SetUint64(batchSize - 1)
from := new(big.Int).Sub(ms.HeadBlock, batchSize)
// Prevent getBlockRange from fetching duplicate blocks.
if ms.MaxBlockRetrieved.Cmp(from) == 1 {
from.Add(ms.MaxBlockRetrieved, big.NewInt(1))
}
// Skip next poll if the latest block is already at the head.
if from.Cmp(ms.HeadBlock) >= 0 {
continue
}

if from.Cmp(zero) < 0 {
from.SetInt64(0)
Expand Down

0 comments on commit 38438d8

Please sign in to comment.