Move a few things around

This commit is contained in:
Asim Aslam
2019-12-09 22:56:26 +00:00
parent 55ab44c8be
commit b29da80539
2 changed files with 425 additions and 406 deletions

View File

@@ -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
}