Skip to content

Commit

Permalink
fix the issue of adding an existed block in legacy sync (#4565)
Browse files Browse the repository at this point in the history
  • Loading branch information
GheisMohammadi authored Nov 17, 2023
1 parent 582a4cf commit 6eda785
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion api/service/legacysync/syncing.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,16 @@ func (ss *StateSync) UpdateBlockAndStatus(block *types.Block, bc core.BlockChain
}

_, err := bc.InsertChain([]*types.Block{block}, false /* verifyHeaders */)
if err != nil {
switch {
case errors.Is(err, core.ErrKnownBlock):
utils.Logger().Info().
Uint64("blockHeight", block.NumberU64()).
Uint64("blockEpoch", block.Epoch().Uint64()).
Str("blockHex", block.Hash().Hex()).
Uint32("ShardID", block.ShardID()).
Msg("[SYNC] UpdateBlockAndStatus: Block exists")
return nil
case err != nil:
utils.Logger().Error().
Err(err).
Msgf(
Expand All @@ -913,6 +922,7 @@ func (ss *StateSync) UpdateBlockAndStatus(block *types.Block, bc core.BlockChain
block.ShardID(),
)
return err
default:
}
utils.Logger().Info().
Uint64("blockHeight", block.NumberU64()).
Expand Down

0 comments on commit 6eda785

Please sign in to comment.