Commit 42cb3f98 authored by vyzo's avatar vyzo

fullfill promise as soon as a message begins validation

parent bfc96c2c
......@@ -91,8 +91,7 @@ func (gt *gossipTracer) GetBrokenPromises() map[peer.ID]int {
var _ internalTracer = (*gossipTracer)(nil)
func (gt *gossipTracer) DeliverMessage(msg *Message) {
// someone delivered a message, stop tracking promises for it
func (gt *gossipTracer) fullfillPromise(msg *Message) {
mid := gt.msgID(msg.Message)
gt.Lock()
......@@ -101,8 +100,13 @@ func (gt *gossipTracer) DeliverMessage(msg *Message) {
delete(gt.promises, mid)
}
func (gt *gossipTracer) DeliverMessage(msg *Message) {
// someone delivered a message, fullfill promises for it
gt.fullfillPromise(msg)
}
func (gt *gossipTracer) RejectMessage(msg *Message, reason string) {
// A message got rejected, so we can stop tracking promises and let the score penalty apply
// A message got rejected, so we can fullfill promises and let the score penalty apply
// from invalid message delivery.
// We do take exception and apply promise penalty regardless in the following cases, where
// the peer delivered an obviously invalid message.
......@@ -113,12 +117,14 @@ func (gt *gossipTracer) RejectMessage(msg *Message, reason string) {
return
}
mid := gt.msgID(msg.Message)
gt.Lock()
defer gt.Unlock()
gt.fullfillPromise(msg)
}
delete(gt.promises, mid)
func (gt *gossipTracer) ValidateMessage(msg *Message) {
// we consider the promise fullfilled as soon as the message begins validation
// if it was a case of signature issue it would have been rejected immediately
// without triggering the Validate trace
gt.fullfillPromise(msg)
}
func (gt *gossipTracer) AddPeer(p peer.ID, proto protocol.ID) {}
......@@ -127,5 +133,4 @@ func (gt *gossipTracer) Join(topic string) {}
func (gt *gossipTracer) Leave(topic string) {}
func (gt *gossipTracer) Graft(p peer.ID, topic string) {}
func (gt *gossipTracer) Prune(p peer.ID, topic string) {}
func (gt *gossipTracer) ValidateMessage(msg *Message) {}
func (gt *gossipTracer) DuplicateMessage(msg *Message) {}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment