Skip to content

Commit

Permalink
fix: always calculate starting block
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 committed Sep 16, 2024
1 parent d2b8051 commit 23263af
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,24 @@ func main() {
panic(err)
}

startBlock, err := blockStore.GetStartBlock(
id,
new(big.Int).SetUint64(config.StartBlock),
config.Latest,
config.FreshStart,
)
if err != nil {
panic(err)
}
if startBlock == nil {
latestBlock, err := client.LatestBlock()
if err != nil {
panic(err)
}
startBlock = latestBlock
}

var evmListener *listener.EVMListener
var startBlock *big.Int
if len(config.StateRootAddresses) > 0 {
eventHandlers := []listener.EventHandler{}
for _, stateRootAddress := range config.StateRootAddresses {
Expand All @@ -108,23 +124,6 @@ func main() {
time.Duration(config.BlockRetryInterval)*time.Second,
big.NewInt(config.BlockConfirmations),
big.NewInt(config.BlockInterval))

startBlock, err = blockStore.GetStartBlock(
id,
new(big.Int).SetUint64(config.StartBlock),
config.Latest,
config.FreshStart,
)
if err != nil {
panic(err)
}
if startBlock == nil {
latestBlock, err := client.LatestBlock()
if err != nil {
panic(err)
}
startBlock = latestBlock
}
}

messageHandler := message.NewMessageHandler()
Expand Down

0 comments on commit 23263af

Please sign in to comment.