Commit 991641b7 authored by acud's avatar acud Committed by GitHub

refactor(pushsync): simplify error handling (#2378)

parent 2690dadd
...@@ -28,7 +28,6 @@ import ( ...@@ -28,7 +28,6 @@ import (
"github.com/ethersphere/bee/pkg/tags" "github.com/ethersphere/bee/pkg/tags"
"github.com/ethersphere/bee/pkg/topology" "github.com/ethersphere/bee/pkg/topology"
"github.com/ethersphere/bee/pkg/tracing" "github.com/ethersphere/bee/pkg/tracing"
"github.com/libp2p/go-libp2p-core/mux"
opentracing "github.com/opentracing/opentracing-go" opentracing "github.com/opentracing/opentracing-go"
) )
...@@ -49,7 +48,7 @@ var ( ...@@ -49,7 +48,7 @@ var (
ErrWarmup = errors.New("node warmup time not complete") ErrWarmup = errors.New("node warmup time not complete")
defaultTTL = 20 * time.Second // request time to live defaultTTL = 20 * time.Second // request time to live
sanctionWait = time.Minute sanctionWait = 5 * time.Minute
timeToWaitForPushsyncToNeighbor = 3 * time.Second // time to wait to get a receipt for a chunk timeToWaitForPushsyncToNeighbor = 3 * time.Second // time to wait to get a receipt for a chunk
nPeersToPushsync = 3 // number of peers to replicate to as receipt is sent upstream nPeersToPushsync = 3 // number of peers to replicate to as receipt is sent upstream
) )
...@@ -362,23 +361,9 @@ func (ps *PushSync) pushToClosest(ctx context.Context, ch swarm.Chunk, retryAllo ...@@ -362,23 +361,9 @@ func (ps *PushSync) pushToClosest(ctx context.Context, ch swarm.Chunk, retryAllo
if err != nil { if err != nil {
var timeToSkip time.Duration var timeToSkip time.Duration
switch { switch {
case errors.Is(err, context.DeadlineExceeded):
// can happen both in NN but also on forwarder nodes.
// if its inside the neighborhood - wait a long time.
// the originator retry will eventually come in and
// would hopefully resolve the situation with the next
// closest peer.
if ps.topologyDriver.IsWithinDepth(ch.Address()) {
timeToSkip = sanctionWait
}
case errors.Is(err, accounting.ErrOverdraft): case errors.Is(err, accounting.ErrOverdraft):
skipPeers = append(skipPeers, peer) skipPeers = append(skipPeers, peer)
case errors.Is(err, mux.ErrReset):
if ps.topologyDriver.IsWithinDepth(ch.Address()) {
timeToSkip = sanctionWait
}
default: default:
// network error, context canceled, eof
timeToSkip = sanctionWait timeToSkip = sanctionWait
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment