Add RefreshSync method for Sync bookkeeping
This commit is contained in:
parent
63edfaa852
commit
0a4bd02503
@ -36,6 +36,8 @@ type node struct {
|
|||||||
network Network
|
network Network
|
||||||
// lastSeen keeps track of node lifetime and updates
|
// lastSeen keeps track of node lifetime and updates
|
||||||
lastSeen time.Time
|
lastSeen time.Time
|
||||||
|
// lastSync keeps track of node last sync request
|
||||||
|
lastSync time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// Id is node ide
|
// Id is node ide
|
||||||
@ -127,7 +129,7 @@ func (n *node) UpdatePeer(peer *node) error {
|
|||||||
return ErrPeerNotFound
|
return ErrPeerNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// RefreshPeer updates node timestamp
|
// RefreshPeer updates node last seen timestamp
|
||||||
// It returns false if the peer has not been found.
|
// It returns false if the peer has not been found.
|
||||||
func (n *node) RefreshPeer(id, link string, now time.Time) error {
|
func (n *node) RefreshPeer(id, link string, now time.Time) error {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
@ -146,6 +148,16 @@ func (n *node) RefreshPeer(id, link string, now time.Time) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RefreshSync refreshes nodes sync time
|
||||||
|
func (n *node) RefreshSync(now time.Time) error {
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
|
n.lastSync = now
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Nodes returns a slice of all nodes in the whole node topology
|
// Nodes returns a slice of all nodes in the whole node topology
|
||||||
func (n *node) Nodes() []Node {
|
func (n *node) Nodes() []Node {
|
||||||
// we need to freeze the network graph here
|
// we need to freeze the network graph here
|
||||||
|
Loading…
Reference in New Issue
Block a user