File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ type Config struct {
94
94
// make this configurable to easily mock the worker used during tests.
95
95
NewWorker func (Peer ) Worker
96
96
97
+ // OnMaxTries gives the caller access to the Peer object once a maximum
98
+ // number of retries have been attempted. The caller can then access the
99
+ // Peer's address and can choose to punish the peer accordingly.
100
+ OnMaxTries func (Peer )
101
+
97
102
// Ranking is used to rank the connected peers when determining who to
98
103
// give work to.
99
104
Ranking PeerRanking
@@ -381,6 +386,14 @@ Loop:
381
386
log .Debugf ("Canceled batch %v" ,
382
387
batchNum )
383
388
389
+ // Since we've reached this query's
390
+ // maximum number of retries, now is the
391
+ // time to call the OnMaxTries callback
392
+ // function if it isn't nil.
393
+ if w .cfg .OnMaxTries != nil {
394
+ w .cfg .OnMaxTries (result .peer )
395
+ }
396
+
384
397
continue Loop
385
398
}
386
399
You can’t perform that action at this time.
0 commit comments