Delivery of responses to retrieve requests.

This commit is contained in:
Daniel A. Nagy 2015-02-13 01:11:19 +01:00
parent d4ff64bf44
commit 8d90ea30c4
2 changed files with 9 additions and 1 deletions

View file

@ -142,11 +142,19 @@ func (self *NetStore) addRetrieveRequest(req *retrieveRequestMsgData) {
defer self.lock.Unlock() defer self.lock.Unlock()
chunk := self.get(req.Key) chunk := self.get(req.Key)
if chunk.Data == nil {
chunk.req.status = reqSearching
} else {
chunk.req.status = reqFound
}
t := time.Now().Add(10 * time.Second) t := time.Now().Add(10 * time.Second)
req.timeout = &t req.timeout = &t
send, timeout := self.strategyUpdateRequest(chunk.req, req) // may change req status send, timeout := self.strategyUpdateRequest(chunk.req, req) // may change req status
dpaLogger.Debugf("Is %v == %v?", send, storeRequestMsg)
if send == storeRequestMsg { if send == storeRequestMsg {
self.deliver(req, chunk) self.deliver(req, chunk)
} else { } else {

View file

@ -289,7 +289,7 @@ func (self *bzzProtocol) retrieve(req *retrieveRequestMsgData) {
} }
func (self *bzzProtocol) store(req *storeRequestMsgData) { func (self *bzzProtocol) store(req *storeRequestMsgData) {
p2p.EncodeMsg(self.rw, storeRequestMsg, req) p2p.EncodeMsg(self.rw, storeRequestMsg, req.Key, req.Size, req.Data, req.Id)
} }
func (self *bzzProtocol) peers(req *peersMsgData) { func (self *bzzProtocol) peers(req *peersMsgData) {