mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
swarm/network: introduce lastActive set when chunk received
This commit is contained in:
parent
ce2a7e23e6
commit
05c62a9922
2 changed files with 4 additions and 4 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Reference in a new issue