Move a few things around
This commit is contained in:
@@ -28,6 +28,8 @@ type node struct {
|
||||
id string
|
||||
// address is node address
|
||||
address string
|
||||
// link on which we communicate with the peer
|
||||
link string
|
||||
// peers are nodes with direct link to this node
|
||||
peers map[string]*node
|
||||
// network returns the node network
|
||||
@@ -127,7 +129,7 @@ func (n *node) UpdatePeer(peer *node) error {
|
||||
|
||||
// RefreshPeer updates node timestamp
|
||||
// It returns false if the peer has not been found.
|
||||
func (n *node) RefreshPeer(id string, now time.Time) error {
|
||||
func (n *node) RefreshPeer(id, link string, now time.Time) error {
|
||||
n.Lock()
|
||||
defer n.Unlock()
|
||||
|
||||
@@ -136,6 +138,9 @@ func (n *node) RefreshPeer(id string, now time.Time) error {
|
||||
return ErrPeerNotFound
|
||||
}
|
||||
|
||||
// set peer link
|
||||
peer.link = link
|
||||
|
||||
if peer.lastSeen.Before(now) {
|
||||
peer.lastSeen = now
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user