Skip to content

Commit

Permalink
set head block differently
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu committed Aug 15, 2023
1 parent 6203cc7 commit 7d0c0f9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions p2p/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,12 @@ func (c *conn) handleNewBlock(ctx context.Context, msg ethp2p.Msg) error {
// Set the head block if newer.
c.headMutex.Lock()
if block.Block.Number().Uint64() > c.head.Number && block.TD.Cmp(c.head.TotalDifficulty) == 1 {
c.head.Hash = block.Block.Hash()
c.head.TotalDifficulty = block.TD
c.head.Number = block.Block.Number().Uint64()
*c.head = HeadBlock{
Hash: block.Block.Hash(),
TotalDifficulty: block.TD,
Number: block.Block.Number().Uint64(),
}

c.logger.Info().Interface("head", c.head).Msg("Setting head block")
}
c.headMutex.Unlock()
Expand Down

0 comments on commit 7d0c0f9

Please sign in to comment.