mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Response propagation and timeout
This commit is contained in:
parent
5d5899ddef
commit
9f4e7db263
1 changed files with 24 additions and 2 deletions
|
|
@ -158,7 +158,24 @@ func (self *netStore) addStoreRequest(req *storeRequestMsgData) {
|
|||
}
|
||||
|
||||
func (self *netStore) propagateResponse(chunk *Chunk) {
|
||||
// send chunk to first requesterCount peer of each Id
|
||||
for id, requesters := range chunk.req.requesters {
|
||||
counter = requesterCount
|
||||
msg := &storeRequestMsgData{
|
||||
Key: chunk.Key,
|
||||
Data: chunk.Data,
|
||||
Size: chunk.Size,
|
||||
Id: id,
|
||||
}
|
||||
for _, req := range requesters {
|
||||
if req.Timeout.After(time.Now()) {
|
||||
go req.peer.store(msg)
|
||||
counter--
|
||||
if counter <= 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *netStore) addRetrieveRequest(req *retrieveRequestMsgData) {
|
||||
|
|
@ -231,7 +248,12 @@ func (self *netStore) peers(req *retrieveRequestMsgData, chunk *Chunk, timeout t
|
|||
}
|
||||
|
||||
func (self *netStore) searchTimeout(rs *requestStatus, req *retrieveRequestMsgData) (timeout time.Time) {
|
||||
return
|
||||
t := time.Now().Add(3 * time.Second)
|
||||
if req.Timeout.Before(t) {
|
||||
return req.Timeout
|
||||
} else {
|
||||
return t
|
||||
}
|
||||
}
|
||||
|
||||
// these should go to cademlia
|
||||
|
|
|
|||
Loading…
Reference in a new issue