Skip to content

Commit d7db10d

Browse files
authored
eth/protocols/snap, p2p/discover: improve zero time checks (ethereum#32214)
1 parent 7364e63 commit d7db10d

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

eth/protocols/snap/sync.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
615615
s.statelessPeers = make(map[string]struct{})
616616
s.lock.Unlock()
617617

618-
if s.startTime == (time.Time{}) {
618+
if s.startTime.IsZero() {
619619
s.startTime = time.Now()
620620
}
621621
// Retrieve the previous sync status from LevelDB and abort if already synced
@@ -1987,9 +1987,7 @@ func (s *Syncer) processAccountResponse(res *accountResponse) {
19871987
func (s *Syncer) processBytecodeResponse(res *bytecodeResponse) {
19881988
batch := s.db.NewBatch()
19891989

1990-
var (
1991-
codes uint64
1992-
)
1990+
var codes uint64
19931991
for i, hash := range res.hashes {
19941992
code := res.codes[i]
19951993

p2p/discover/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ func (tab *Table) addReplacement(b *bucket, n *enode.Node) {
562562
}
563563

564564
func (tab *Table) nodeAdded(b *bucket, n *tableNode) {
565-
if n.addedToTable == (time.Time{}) {
565+
if n.addedToTable.IsZero() {
566566
n.addedToTable = time.Now()
567567
}
568568
n.addedToBucket = time.Now()

0 commit comments

Comments
 (0)