Skip to content

Commit

Permalink
fix fork persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 17, 2024
1 parent 65f7294 commit 3da41a4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions indexer/beacon/forkcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,11 @@ func (cache *forkCache) processBlock(block *Block) (ForkKey, error) {
return err
}

err = db.UpdateUnfinalizedBlockForkId(fork1Roots, uint64(fork1.forkId), tx)
if err != nil {
return err
if len(fork1Roots) > 0 {
err = db.UpdateUnfinalizedBlockForkId(fork1Roots, uint64(fork1.forkId), tx)
if err != nil {
return err
}
}

cache.indexer.logger.Infof("fork %v created (base %v [%v], head %v [%v], updated blocks: %v)", fork1.forkId, fork1.baseSlot, fork1.baseRoot.String(), fork1.leafSlot, fork1.leafRoot.String(), len(fork1Roots))
Expand All @@ -446,9 +448,11 @@ func (cache *forkCache) processBlock(block *Block) (ForkKey, error) {
return err
}

err = db.UpdateUnfinalizedBlockForkId(fork2Roots, uint64(fork2.forkId), tx)
if err != nil {
return err
if len(fork2Roots) > 0 {
err = db.UpdateUnfinalizedBlockForkId(fork2Roots, uint64(fork2.forkId), tx)
if err != nil {
return err
}
}

cache.indexer.logger.Infof("fork %v created (base %v [%v], head %v [%v], updated blocks: %v)", fork2.forkId, fork2.baseSlot, fork2.baseRoot.String(), fork2.leafSlot, fork2.leafRoot.String(), len(fork2Roots))
Expand Down

0 comments on commit 3da41a4

Please sign in to comment.