mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
do not forward store request to the peer we received it from
This commit is contained in:
parent
638bc6d364
commit
8ad5bc8450
2 changed files with 7 additions and 3 deletions
|
|
@ -61,6 +61,7 @@ type Chunk struct {
|
||||||
req *requestStatus //
|
req *requestStatus //
|
||||||
wg *sync.WaitGroup
|
wg *sync.WaitGroup
|
||||||
dbStored chan bool
|
dbStored chan bool
|
||||||
|
source peer
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChunkStore interface {
|
type ChunkStore interface {
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ func (self *NetStore) put(entry *Chunk) {
|
||||||
func (self *NetStore) addStoreRequest(req *storeRequestMsgData) {
|
func (self *NetStore) addStoreRequest(req *storeRequestMsgData) {
|
||||||
self.lock.Lock()
|
self.lock.Lock()
|
||||||
defer self.lock.Unlock()
|
defer self.lock.Unlock()
|
||||||
dpaLogger.Debugf("NetStore.addStoreRequest: req = %#v", req)
|
dpaLogger.Debugf("NetStore.addStoreRequest: req = %v", req)
|
||||||
chunk, err := self.localStore.Get(req.Key)
|
chunk, err := self.localStore.Get(req.Key)
|
||||||
dpaLogger.Debugf("NetStore.addStoreRequest: chunk reference %p", chunk)
|
dpaLogger.Debugf("NetStore.addStoreRequest: chunk reference %p", chunk)
|
||||||
// we assume that a returned chunk is the one stored in the memory cache
|
// we assume that a returned chunk is the one stored in the memory cache
|
||||||
|
|
@ -114,6 +114,7 @@ func (self *NetStore) addStoreRequest(req *storeRequestMsgData) {
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
chunk.source = req.peer
|
||||||
self.put(chunk)
|
self.put(chunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,7 +225,7 @@ only add if less than requesterCount peers forwarded the same request id so far
|
||||||
note this is done irrespective of status (searching or found/timedOut)
|
note this is done irrespective of status (searching or found/timedOut)
|
||||||
*/
|
*/
|
||||||
func (self *NetStore) addRequester(rs *requestStatus, req *retrieveRequestMsgData) {
|
func (self *NetStore) addRequester(rs *requestStatus, req *retrieveRequestMsgData) {
|
||||||
dpaLogger.Debugf("NetStore.addRequester: key %064x - add peer [%#v] to req.Id %064x", req.Key, req.peer, req.Id)
|
dpaLogger.Debugf("NetStore.addRequester: key %064x - add peer [%v] to req.Id %064x", req.Key, req.peer, req.Id)
|
||||||
list := rs.requesters[int64(req.Id)]
|
list := rs.requesters[int64(req.Id)]
|
||||||
rs.requesters[int64(req.Id)] = append(list, req)
|
rs.requesters[int64(req.Id)] = append(list, req)
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +295,9 @@ func (self *NetStore) store(chunk *Chunk) {
|
||||||
Id: uint64(id),
|
Id: uint64(id),
|
||||||
}
|
}
|
||||||
for _, peer := range self.hive.getPeers(chunk.Key, 0) {
|
for _, peer := range self.hive.getPeers(chunk.Key, 0) {
|
||||||
go peer.store(req)
|
if peer.Addr() != chunk.source.Addr() {
|
||||||
|
go peer.store(req)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue