Skip to content

Commit 57f959a

Browse files
committed
p2p/enode: use localItemKey for local sequence number
I added localItemKey for this purpose in ethereum#18963, but then forgot to actually use it. This changes the database layout yet again and requires bumping the version number.
1 parent cf147c7 commit 57f959a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

p2p/enode/nodedb.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const (
5757
const (
5858
dbNodeExpiration = 24 * time.Hour // Time after which an unseen node should be dropped.
5959
dbCleanupCycle = time.Hour // Time period for running the expiration task.
60-
dbVersion = 8
60+
dbVersion = 9
6161
)
6262

6363
var zeroIP = make(net.IP, 16)
@@ -380,12 +380,12 @@ func (db *DB) UpdateFindFails(id ID, ip net.IP, fails int) error {
380380

381381
// LocalSeq retrieves the local record sequence counter.
382382
func (db *DB) localSeq(id ID) uint64 {
383-
return db.fetchUint64(nodeItemKey(id, zeroIP, dbLocalSeq))
383+
return db.fetchUint64(localItemKey(id, dbLocalSeq))
384384
}
385385

386386
// storeLocalSeq stores the local record sequence counter.
387387
func (db *DB) storeLocalSeq(id ID, n uint64) {
388-
db.storeUint64(nodeItemKey(id, zeroIP, dbLocalSeq), n)
388+
db.storeUint64(localItemKey(id, dbLocalSeq), n)
389389
}
390390

391391
// QuerySeeds retrieves random nodes to be used as potential seed nodes

p2p/enode/nodedb_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestDBNodeItemKey(t *testing.T) {
7171
if id != keytestID {
7272
t.Errorf("splitNodeItemKey returned wrong ID: %v", id)
7373
}
74-
if !bytes.Equal(ip, wantIP) {
74+
if !ip.Equal(wantIP) {
7575
t.Errorf("splitNodeItemKey returned wrong IP: %v", ip)
7676
}
7777
if field != wantField {

0 commit comments

Comments
 (0)