From 3da41a44d30153633f7f7dab289eaaa89643fe9a Mon Sep 17 00:00:00 2001 From: pk910 Date: Sat, 17 Aug 2024 13:15:13 +0200 Subject: [PATCH] fix fork persistence --- indexer/beacon/forkcache.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/indexer/beacon/forkcache.go b/indexer/beacon/forkcache.go index ffe16c2d..e567251e 100644 --- a/indexer/beacon/forkcache.go +++ b/indexer/beacon/forkcache.go @@ -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)) @@ -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))