Skip to content

Commit

Permalink
final cleanup fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelArtists committed Nov 12, 2024
1 parent 63debe8 commit b113555
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions p2p/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,26 +360,20 @@ func (c *conn) addBlockHash(hash common.Hash) {
// Helper method to check if a block hash is already in blockHashes.
func (c *conn) hasSeenBlockHash(hash common.Hash) bool {
now := time.Now()
found := false

for e := c.blockHashes.Front(); e != nil; {
next := e.Next()
for e := c.blockHashes.Front(); e != nil; e = e.Next() {
entry := e.Value.(BlockHashEntry)

// Check if the hash matches. We can short circuit here because there will
// be block hashes that we haven't seen before, which will make a full
// iteration of the blockHashes linked list.
if entry.hash.Cmp(hash) == 0 {
return true
}
// Remove entries older than blockHashTTL.
if now.Sub(entry.time) > blockHashTTL {
c.blockHashes.Remove(e)
} else {
// Check if the hash matches.
if entry.hash.Cmp(hash) == 0 {
found = true
}
}

e = next
}

return found
return false
}

func (c *conn) handleTransactions(ctx context.Context, msg ethp2p.Msg) error {
Expand Down

0 comments on commit b113555

Please sign in to comment.