overflows

(cherry picked from commit 4c8651026a)
This commit is contained in:
tycho garen
2022-06-10 16:00:25 -04:00
parent f772dccf3b
commit e38d5b7547
+9 -1
View File
@@ -39,7 +39,7 @@ const (
)
// PeerScore is a numeric score assigned to a peer (higher is better).
type PeerScore int
type PeerScore int16
const (
PeerScorePersistent PeerScore = math.MaxInt16 // persistent peers
@@ -950,8 +950,16 @@ func (m *PeerManager) processPeerEvent(pu PeerUpdate) {
switch pu.Status {
case PeerStatusBad:
if m.store.peers[pu.NodeID].MutableScore == math.MinInt16 {
// TODO: should we inactivate the peer at this
// point?
return
}
m.store.peers[pu.NodeID].MutableScore--
case PeerStatusGood:
if m.store.peers[pu.NodeID].MutableScore == math.MaxInt16 {
return
}
m.store.peers[pu.NodeID].MutableScore++
}
}