Skip to content

Commit

Permalink
Merge pull request #99 from ethpandaops/pk910/fix-fork-insert
Browse files Browse the repository at this point in the history
fix fork persistence
  • Loading branch information
pk910 authored Aug 17, 2024
2 parents 65f7294 + 3da41a4 commit 6ec4207
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 6ec4207

Please sign in to comment.