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 {
9494 // make this configurable to easily mock the worker used during tests.
9595 NewWorker func (Peer ) Worker
9696
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+
97102 // Ranking is used to rank the connected peers when determining who to
98103 // give work to.
99104 Ranking PeerRanking
@@ -381,6 +386,14 @@ Loop:
381386 log .Debugf ("Canceled batch %v" ,
382387 batchNum )
383388
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+
384397 continue Loop
385398 }
386399
You can’t perform that action at this time.
0 commit comments