mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
revert seq num to time
Signed-off-by: Chen Kai <281165273grape@gmail.com>
This commit is contained in:
parent
79523ca21c
commit
618559ee75
3 changed files with 1 additions and 43 deletions
|
|
@ -53,7 +53,6 @@ func TestLocalNode(t *testing.T) {
|
||||||
|
|
||||||
// This test checks that the sequence number is persisted between restarts.
|
// This test checks that the sequence number is persisted between restarts.
|
||||||
func TestLocalNodeSeqPersist(t *testing.T) {
|
func TestLocalNodeSeqPersist(t *testing.T) {
|
||||||
t.Skip("Skipping this test")
|
|
||||||
timestamp := nowMilliseconds()
|
timestamp := nowMilliseconds()
|
||||||
|
|
||||||
ln, db := newLocalNodeForTesting()
|
ln, db := newLocalNodeForTesting()
|
||||||
|
|
|
||||||
|
|
@ -159,47 +159,6 @@ func Parse(validSchemes enr.IdentityScheme, input string) (*Node, error) {
|
||||||
return New(validSchemes, &r)
|
return New(validSchemes, &r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Portal network not filter multicast address, any other way to support this?
|
|
||||||
func ParseForAddEnr(validSchemes enr.IdentityScheme, input string) (*Node, error) {
|
|
||||||
if strings.HasPrefix(input, "enode://") {
|
|
||||||
return ParseV4(input)
|
|
||||||
}
|
|
||||||
if !strings.HasPrefix(input, "enr:") {
|
|
||||||
return nil, errMissingPrefix
|
|
||||||
}
|
|
||||||
bin, err := base64.RawURLEncoding.DecodeString(input[4:])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var r enr.Record
|
|
||||||
if err := rlp.DecodeBytes(bin, &r); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var n *Node
|
|
||||||
if n, err = New(validSchemes, &r); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var ip4 netip.Addr
|
|
||||||
var ip6 netip.Addr
|
|
||||||
n.Load((*enr.IPv4Addr)(&ip4))
|
|
||||||
n.Load((*enr.IPv6Addr)(&ip6))
|
|
||||||
valid4 := ip4.IsValid()
|
|
||||||
valid6 := ip6.IsValid()
|
|
||||||
switch {
|
|
||||||
case valid4 && valid6:
|
|
||||||
if localityScore(ip4) >= localityScore(ip6) {
|
|
||||||
n.setIP4(ip4)
|
|
||||||
} else {
|
|
||||||
n.setIP6(ip6)
|
|
||||||
}
|
|
||||||
case valid4:
|
|
||||||
n.setIP4(ip4)
|
|
||||||
case valid6:
|
|
||||||
n.setIP6(ip6)
|
|
||||||
}
|
|
||||||
return n, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ID returns the node identifier.
|
// ID returns the node identifier.
|
||||||
func (n *Node) ID() ID {
|
func (n *Node) ID() ID {
|
||||||
return n.id
|
return n.id
|
||||||
|
|
|
||||||
|
|
@ -434,7 +434,7 @@ func (db *DB) localSeq(id ID) uint64 {
|
||||||
if seq := db.fetchUint64(localItemKey(id, dbLocalSeq)); seq > 0 {
|
if seq := db.fetchUint64(localItemKey(id, dbLocalSeq)); seq > 0 {
|
||||||
return seq
|
return seq
|
||||||
}
|
}
|
||||||
return 1
|
return nowMilliseconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
// storeLocalSeq stores the local record sequence counter.
|
// storeLocalSeq stores the local record sequence counter.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue