diff --git a/p2p/enode/localnode.go b/p2p/enode/localnode.go index d8fa6a92026..6425560b020 100644 --- a/p2p/enode/localnode.go +++ b/p2p/enode/localnode.go @@ -305,12 +305,3 @@ func (ln *LocalNode) bumpSeq() { ln.seq++ ln.db.storeLocalSeq(ln.id, ln.seq) } - -// nowMilliseconds gives the current timestamp at millisecond precision. -func nowMilliseconds() uint64 { - ns := time.Now().UnixNano() - if ns < 0 { - return 0 - } - return uint64(ns / 1000 / 1000) -} diff --git a/p2p/enode/localnode_test.go b/p2p/enode/localnode_test.go index 86b962a74ee..5ddc302d653 100644 --- a/p2p/enode/localnode_test.go +++ b/p2p/enode/localnode_test.go @@ -21,6 +21,7 @@ import ( "net" "net/netip" "testing" + "time" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/p2p/enr" @@ -53,7 +54,7 @@ func TestLocalNode(t *testing.T) { // This test checks that the sequence number is persisted between restarts. func TestLocalNodeSeqPersist(t *testing.T) { - timestamp := nowMilliseconds() + timestamp := uint64(time.Now().UnixMilli()) ln, db := newLocalNodeForTesting() defer db.Close() diff --git a/p2p/enode/nodedb.go b/p2p/enode/nodedb.go index 51e554e68ad..2cd211e2c20 100644 --- a/p2p/enode/nodedb.go +++ b/p2p/enode/nodedb.go @@ -434,7 +434,7 @@ func (db *DB) localSeq(id ID) uint64 { if seq := db.fetchUint64(localItemKey(id, dbLocalSeq)); seq > 0 { return seq } - return nowMilliseconds() + return uint64(time.Now().UnixMilli()) } // storeLocalSeq stores the local record sequence counter.