From d4ff64bf44953cfd26ea65198ed1701db43d68a7 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Fri, 13 Feb 2015 00:11:48 +0100 Subject: [PATCH] Time references changed --- bzz/netstore.go | 13 +++++++------ bzz/protocol.go | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bzz/netstore.go b/bzz/netstore.go index be08e62dad..ce570f7af8 100644 --- a/bzz/netstore.go +++ b/bzz/netstore.go @@ -104,7 +104,7 @@ func (self *NetStore) Get(key Key) (chunk *Chunk, err error) { id := generateId() timeout := time.Now().Add(searchTimeout) if chunk.Data == nil { - self.startSearch(chunk, id, timeout) + self.startSearch(chunk, id, &timeout) } else { return } @@ -142,7 +142,8 @@ func (self *NetStore) addRetrieveRequest(req *retrieveRequestMsgData) { defer self.lock.Unlock() chunk := self.get(req.Key) - req.timeout = time.Now().Add(10 * time.Second) + t := time.Now().Add(10 * time.Second) + req.timeout = &t send, timeout := self.strategyUpdateRequest(chunk.req, req) // may change req status @@ -150,9 +151,9 @@ func (self *NetStore) addRetrieveRequest(req *retrieveRequestMsgData) { self.deliver(req, chunk) } else { // we might need chunk.req to cache relevant peers response, or would it expire? - self.peers(req, chunk, *timeout) + self.peers(req, chunk, timeout) if timeout != nil { - self.startSearch(chunk, int64(req.Id), *timeout) + self.startSearch(chunk, int64(req.Id), timeout) } } @@ -273,8 +274,8 @@ func (self *NetStore) peers(req *retrieveRequestMsgData, chunk *Chunk, timeout * func (self *NetStore) searchTimeout(rs *requestStatus, req *retrieveRequestMsgData) (timeout *time.Time) { t := time.Now().Add(searchTimeout) - if req.timeout.Before(t) { - return &req.timeout + if req.timeout != nil && req.timeout.Before(t) { + return req.timeout } else { return &t } diff --git a/bzz/protocol.go b/bzz/protocol.go index c56e672e71..e6f9eb996e 100644 --- a/bzz/protocol.go +++ b/bzz/protocol.go @@ -78,8 +78,8 @@ type storeRequestMsgData struct { Data []byte // is this needed? // optional Id uint64 // - RequestTimeout *time.Time // expiry for forwarding - StorageTimeout *time.Time // expiry of content + requestTimeout *time.Time // expiry for forwarding + storageTimeout *time.Time // expiry of content Metadata metaData // // peer peer @@ -119,7 +119,7 @@ It is unclear if PeersMsg with an empty Key has a special meaning or just mean t */ type peersMsgData struct { Peers []*peerAddr // - Timeout *time.Time // indicate whether responder is expected to deliver content + timeout *time.Time // indicate whether responder is expected to deliver content Key Key // if a response to a retrieval request Id uint64 // if a response to a retrieval request //