disallow duplicate score inspectors

This commit is contained in:
vyzo 2020-07-29 20:09:06 +03:00
parent e6559f59c0
commit 0f6aeb23d7
1 changed files with 6 additions and 1 deletions

View File

@ -152,6 +152,10 @@ func WithPeerScoreInspect(inspect interface{}, period time.Duration) Option {
return fmt.Errorf("peer scoring is not enabled")
}
if gs.score.inspect != nil || gs.score.inspectEx != nil {
return fmt.Errorf("duplicate peer score inspector")
}
switch i := inspect.(type) {
case PeerScoreInspectFn:
gs.score.inspect = i
@ -352,7 +356,8 @@ func (ps *peerScore) background(ctx context.Context) {
func (ps *peerScore) inspectScores() {
if ps.inspect != nil {
ps.inspectScoresSimple()
} else if ps.inspectEx != nil {
}
if ps.inspectEx != nil {
ps.inspectScoresExtended()
}
}