diff --git a/swarm/network/hive.go b/swarm/network/hive.go index 904a687ad4..b1408bac59 100644 --- a/swarm/network/hive.go +++ b/swarm/network/hive.go @@ -294,7 +294,7 @@ func (self *peer) Url() string { // TODO take into account traffic func (self *peer) LastActive() time.Time { - return time.Now() + return self.lastActive } // reads the serialised form of sync state persisted as the 'Meta' attribute @@ -335,9 +335,6 @@ func saveSync(record *kademlia.NodeRecord, node kademlia.Node) { // sends relevant peer data given by the kademlia hive to the requester // TODO: remember peers sent for duration of the session, only new peers sent func (self *Hive) peers(req *retrieveRequestMsgData) { - // FIXME: should check req.MaxPeers but then should not default to zero or make sure we set it when sending retrieveRequests - // we might need chunk.req to cache relevant peers response, - // hive change would expire it if req != nil && req.MaxPeers >= 0 { var addrs []*peerAddr if req.timeout == nil || time.Now().Before(*(req.timeout)) { diff --git a/swarm/network/protocol.go b/swarm/network/protocol.go index 7e45fde094..ce320aa8ef 100644 --- a/swarm/network/protocol.go +++ b/swarm/network/protocol.go @@ -79,6 +79,7 @@ type bzz struct { rw p2p.MsgReadWriter // messageReadWriter to send messages to errors *errs.Errors // errors table backend bind.Backend + lastActive time.Time swap *swap.Swap // swap instance for the peer connection swapParams *bzzswap.SwapParams // swap settings both local and remote @@ -229,6 +230,8 @@ func (self *bzz) handle() error { if len(req.SData) < 9 { return self.protoError(ErrDecode, "<- %v: Data too short (%v)", msg) } + // last Active time is set only when receiving chunks + self.lastActive = time.Now() glog.V(logger.Detail).Infof("[BZZ] incoming store request: %s", req.String()) // swap accounting is done within forwarding self.storage.HandleStoreRequestMsg(&req, &peer{bzz: self})