also account for duplicates in gating decisions
This commit is contained in:
parent
ec44a63c9f
commit
ff1b1a9772
|
@ -29,7 +29,7 @@ type peerGaterStats struct {
|
||||||
connected bool
|
connected bool
|
||||||
expire time.Time
|
expire time.Time
|
||||||
|
|
||||||
deliver, ignore, reject float64
|
deliver, duplicate, ignore, reject float64
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPeerGater is a gossipsub router option that enables reactive validation queue
|
// WithPeerGater is a gossipsub router option that enables reactive validation queue
|
||||||
|
@ -108,6 +108,11 @@ func (pg *peerGater) decayStats() {
|
||||||
st.deliver = 0
|
st.deliver = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
st.duplicate *= pg.decay
|
||||||
|
if st.duplicate < DefaultDecayToZero {
|
||||||
|
st.duplicate = 0
|
||||||
|
}
|
||||||
|
|
||||||
st.ignore *= pg.decay
|
st.ignore *= pg.decay
|
||||||
if st.ignore < DefaultDecayToZero {
|
if st.ignore < DefaultDecayToZero {
|
||||||
st.ignore = 0
|
st.ignore = 0
|
||||||
|
@ -154,7 +159,7 @@ func (pg *peerGater) AcceptFrom(p peer.ID) AcceptStatus {
|
||||||
|
|
||||||
st := pg.getPeerStats(p)
|
st := pg.getPeerStats(p)
|
||||||
|
|
||||||
total := st.deliver + st.ignore + st.reject
|
total := st.deliver + st.duplicate + st.ignore + st.reject
|
||||||
if total == 0 {
|
if total == 0 {
|
||||||
return AcceptAll
|
return AcceptAll
|
||||||
}
|
}
|
||||||
|
@ -236,5 +241,12 @@ func (pg *peerGater) RejectMessage(msg *Message, reason string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pg *peerGater) DuplicateMessage(msg *Message) {}
|
func (pg *peerGater) DuplicateMessage(msg *Message) {
|
||||||
func (pg *peerGater) ThrottlePeer(p peer.ID) {}
|
pg.Lock()
|
||||||
|
defer pg.Unlock()
|
||||||
|
|
||||||
|
st := pg.getPeerStats(msg.ReceivedFrom)
|
||||||
|
st.duplicate++
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pg *peerGater) ThrottlePeer(p peer.ID) {}
|
||||||
|
|
Loading…
Reference in New Issue