Skip to content

Commit

Permalink
shorten the prefix string
Browse files Browse the repository at this point in the history
Signed-off-by: Chengxuan Xing <[email protected]>
  • Loading branch information
Chengxuan committed Nov 14, 2024
1 parent 8bbc812 commit 7914431
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/ethereum/blocklistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ func (bl *blockListener) rebuildCanonicalChain() *list.Element {
var expectedParentHash string
if lastValidBlock != nil {
nextBlockNumber = lastValidBlock.number + 1
log.L(bl.ctx).Infof("Block listener in-memory canonical chain partially rebuilding from block %d", nextBlockNumber)
log.L(bl.ctx).Infof("Canonical chain partially rebuilding from block %d", nextBlockNumber)
expectedParentHash = lastValidBlock.hash
} else {
firstBlock := bl.canonicalChain.Front()
if firstBlock == nil || firstBlock.Value == nil {
return nil
}
nextBlockNumber = firstBlock.Value.(*minimalBlockInfo).number
log.L(bl.ctx).Warnf("Block listener in-memory canonical chain re-initialized at block %d", nextBlockNumber)
log.L(bl.ctx).Warnf("Canonical chain re-initialized at block %d", nextBlockNumber)
// Clear out the whole chain
bl.canonicalChain = bl.canonicalChain.Init()
}
Expand All @@ -413,7 +413,7 @@ func (bl *blockListener) rebuildCanonicalChain() *list.Element {
}
}
if bi == nil {
log.L(bl.ctx).Infof("Block listener in-memory canonical chain rebuilt the chain to the head block %d", nextBlockNumber-1)
log.L(bl.ctx).Infof("Canonical chain rebuilt the chain to the head block %d", nextBlockNumber-1)
break
}
mbi := &minimalBlockInfo{
Expand All @@ -425,7 +425,7 @@ func (bl *blockListener) rebuildCanonicalChain() *list.Element {
// It's possible the chain will change while we're doing this, and we fall back to the next block notification
// to sort that out.
if expectedParentHash != "" && mbi.parentHash != expectedParentHash {
log.L(bl.ctx).Infof("Block listener in-memory canonical chain rebuilding stopped at block: %d due to mismatch hash for parent block (%d): %s (expected: %s)", nextBlockNumber, nextBlockNumber-1, mbi.parentHash, expectedParentHash)
log.L(bl.ctx).Infof("Canonical chain rebuilding stopped at block: %d due to mismatch hash for parent block (%d): %s (expected: %s)", nextBlockNumber, nextBlockNumber-1, mbi.parentHash, expectedParentHash)
break
}
expectedParentHash = mbi.hash
Expand Down Expand Up @@ -458,12 +458,12 @@ func (bl *blockListener) trimToLastValidBlock() (lastValidBlock *minimalBlockInf
currentViewBlock := lastElem.Value.(*minimalBlockInfo)
if startingNumber == nil {
startingNumber = &currentViewBlock.number
log.L(bl.ctx).Debugf("Block listener in-memory canonical chain checking from last block: %d", startingNumber)
log.L(bl.ctx).Debugf("Canonical chain checking from last block: %d", startingNumber)
}
var freshBlockInfo *blockInfoJSONRPC
var reason ffcapi.ErrorReason
err := bl.c.retry.Do(bl.ctx, "rebuild listener canonical chain", func(_ int) (retry bool, err error) {
log.L(bl.ctx).Debugf("Block listener in-memory canonical chain validating block: %d", currentViewBlock.number)
log.L(bl.ctx).Debugf("Canonical chain validating block: %d", currentViewBlock.number)
freshBlockInfo, reason, err = bl.getBlockInfoByNumber(bl.ctx, currentViewBlock.number, false, "")
return reason != ffcapi.ErrorReasonNotFound, err
})
Expand All @@ -474,7 +474,7 @@ func (bl *blockListener) trimToLastValidBlock() (lastValidBlock *minimalBlockInf
}

if freshBlockInfo != nil && freshBlockInfo.Hash.String() == currentViewBlock.hash {
log.L(bl.ctx).Debugf("Block listener in-memory canonical chain found last valid block %d", currentViewBlock.number)
log.L(bl.ctx).Debugf("Canonical chain found last valid block %d", currentViewBlock.number)
lastValidBlock = currentViewBlock
// Trim everything after this point, as it's invalidated
nextElem := lastElem.Next()
Expand All @@ -489,7 +489,7 @@ func (bl *blockListener) trimToLastValidBlock() (lastValidBlock *minimalBlockInf
}

if startingNumber != nil && lastValidBlock != nil && *startingNumber != lastValidBlock.number {
log.L(bl.ctx).Debugf("Block listener in-memory canonical chain trimmed from block %d to block %d (total number of in memory blocks: %d)", startingNumber, lastValidBlock.number, bl.unstableHeadLength)
log.L(bl.ctx).Debugf("Canonical chain trimmed from block %d to block %d (total number of in memory blocks: %d)", startingNumber, lastValidBlock.number, bl.unstableHeadLength)
}
return lastValidBlock
}
Expand Down

0 comments on commit 7914431

Please sign in to comment.