aboutsummaryrefslogtreecommitdiffstats
path: root/les/retrieve.go
diff options
context:
space:
mode:
Diffstat (limited to 'les/retrieve.go')
-rw-r--r--les/retrieve.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/les/retrieve.go b/les/retrieve.go
index b060e0b0d..dd15b56ac 100644
--- a/les/retrieve.go
+++ b/les/retrieve.go
@@ -22,6 +22,7 @@ import (
"context"
"crypto/rand"
"encoding/binary"
+ "fmt"
"sync"
"time"
@@ -111,12 +112,14 @@ func newRetrieveManager(peers *peerSet, dist *requestDistributor, serverPool pee
// that is delivered through the deliver function and successfully validated by the
// validator callback. It returns when a valid answer is delivered or the context is
// cancelled.
-func (rm *retrieveManager) retrieve(ctx context.Context, reqID uint64, req *distReq, val validatorFunc) error {
+func (rm *retrieveManager) retrieve(ctx context.Context, reqID uint64, req *distReq, val validatorFunc, shutdown chan struct{}) error {
sentReq := rm.sendReq(reqID, req, val)
select {
case <-sentReq.stopCh:
case <-ctx.Done():
sentReq.stop(ctx.Err())
+ case <-shutdown:
+ sentReq.stop(fmt.Errorf("Client is shutting down"))
}
return sentReq.getError()
}