swarm/network: increase search timeout to 3sec.

This commit is contained in:
Anton Evangelatov 2019-03-11 17:34:43 +01:00
parent 0e310a937a
commit 273ec941fb
3 changed files with 6 additions and 3 deletions

View file

@ -30,7 +30,7 @@ import (
) )
const ( const (
defaultSearchTimeout = 1 * time.Second defaultSearchTimeout = 3 * time.Second
// maximum number of forwarded requests (hops), to make sure requests are not // maximum number of forwarded requests (hops), to make sure requests are not
// forwarded forever in peer loops // forwarded forever in peer loops
maxHopCount uint8 = 20 maxHopCount uint8 = 20
@ -272,7 +272,6 @@ func (f *Fetcher) run(peers *sync.Map) {
// * the peer's address is removed from prospective sources, and // * the peer's address is removed from prospective sources, and
// * a go routine is started that reports on the gone channel if the peer is disconnected (or terminated their streamer) // * a go routine is started that reports on the gone channel if the peer is disconnected (or terminated their streamer)
func (f *Fetcher) doRequest(gone chan *enode.ID, peersToSkip *sync.Map, sources []*enode.ID, hopCount uint8) ([]*enode.ID, error) { func (f *Fetcher) doRequest(gone chan *enode.ID, peersToSkip *sync.Map, sources []*enode.ID, hopCount uint8) ([]*enode.ID, error) {
log.Trace("fetcher.doRequest", "request addr", f.addr)
var i int var i int
var sourceID *enode.ID var sourceID *enode.ID
@ -290,6 +289,7 @@ func (f *Fetcher) doRequest(gone chan *enode.ID, peersToSkip *sync.Map, sources
for i = 0; i < len(sources); i++ { for i = 0; i < len(sources); i++ {
req.Source = sources[i] req.Source = sources[i]
var err error var err error
log.Trace("fetcher.doRequest", "request addr", f.addr, "peer", req.Source.String())
sourceID, quit, err = f.protoRequestFunc(f.ctx, req) sourceID, quit, err = f.protoRequestFunc(f.ctx, req)
if err == nil { if err == nil {
// remove the peer from known sources // remove the peer from known sources

View file

@ -228,7 +228,7 @@ func (d *Delivery) handleChunkDeliveryMsg(ctx context.Context, sp *Peer, req *Ch
spanId := fmt.Sprintf("stream.send.request.%v.%v", sp.ID(), req.Addr) spanId := fmt.Sprintf("stream.send.request.%v.%v", sp.ID(), req.Addr)
span := tracing.ShiftSpanByKey(spanId) span := tracing.ShiftSpanByKey(spanId)
log.Trace("handle.chunk.delivery", "ref", req.Addr) log.Trace("handle.chunk.delivery", "ref", req.Addr, "from peer", sp.ID())
go func() { go func() {
defer osp.Finish() defer osp.Finish()

View file

@ -87,7 +87,9 @@ func (n *NetStore) Put(ctx context.Context, ch Chunk) error {
// if chunk is now put in the store, check if there was an active fetcher and call deliver on it // if chunk is now put in the store, check if there was an active fetcher and call deliver on it
// (this delivers the chunk to requestors via the fetcher) // (this delivers the chunk to requestors via the fetcher)
log.Debug("n.getFetcher", "ref", ch.Address())
if f := n.getFetcher(ch.Address()); f != nil { if f := n.getFetcher(ch.Address()); f != nil {
log.Debug("n.getFetcher deliver", "ref", ch.Address())
f.deliver(ctx, ch) f.deliver(ctx, ch)
} }
return nil return nil
@ -341,5 +343,6 @@ func (f *fetcher) deliver(ctx context.Context, ch Chunk) {
f.chunk = ch f.chunk = ch
// closing the deliveredC channel will terminate ongoing requests // closing the deliveredC channel will terminate ongoing requests
close(f.deliveredC) close(f.deliveredC)
log.Debug("n.getFetcher close deliveredC", "ref", ch.Address())
}) })
} }