@@ -45,7 +45,7 @@ const (
45
45
// current process. Setting ENR entries via the Set method updates the record. A new version
46
46
// of the record is signed on demand when the Node method is called.
47
47
type LocalNode struct {
48
- cur atomic.Value // holds a non-nil node pointer while the record is up-to-date
48
+ cur atomic.Pointer [ Node ] // holds a non-nil node pointer while the record is up-to-date
49
49
50
50
id ID
51
51
key * ecdsa.PrivateKey
@@ -82,7 +82,7 @@ func NewLocalNode(db *DB, key *ecdsa.PrivateKey) *LocalNode {
82
82
}
83
83
ln .seq = db .localSeq (ln .id )
84
84
ln .update = time .Now ()
85
- ln .cur .Store (( * Node )( nil ) )
85
+ ln .cur .Store (nil )
86
86
return ln
87
87
}
88
88
@@ -94,7 +94,7 @@ func (ln *LocalNode) Database() *DB {
94
94
// Node returns the current version of the local node record.
95
95
func (ln * LocalNode ) Node () * Node {
96
96
// If we have a valid record, return that
97
- n := ln .cur .Load ().( * Node )
97
+ n := ln .cur .Load ()
98
98
if n != nil {
99
99
return n
100
100
}
@@ -105,7 +105,7 @@ func (ln *LocalNode) Node() *Node {
105
105
106
106
// Double check the current record, since multiple goroutines might be waiting
107
107
// on the write mutex.
108
- if n = ln .cur .Load ().( * Node ) ; n != nil {
108
+ if n = ln .cur .Load (); n != nil {
109
109
return n
110
110
}
111
111
@@ -121,7 +121,7 @@ func (ln *LocalNode) Node() *Node {
121
121
122
122
ln .sign ()
123
123
ln .update = time .Now ()
124
- return ln .cur .Load ().( * Node )
124
+ return ln .cur .Load ()
125
125
}
126
126
127
127
// Seq returns the current sequence number of the local node record.
@@ -276,11 +276,11 @@ func (e *lnEndpoint) get() (newIP net.IP, newPort uint16) {
276
276
}
277
277
278
278
func (ln * LocalNode ) invalidate () {
279
- ln .cur .Store (( * Node )( nil ) )
279
+ ln .cur .Store (nil )
280
280
}
281
281
282
282
func (ln * LocalNode ) sign () {
283
- if n := ln .cur .Load ().( * Node ) ; n != nil {
283
+ if n := ln .cur .Load (); n != nil {
284
284
return // no changes
285
285
}
286
286
0 commit comments