Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-pubsub
Commits
42cb3f98
Commit
42cb3f98
authored
Aug 21, 2020
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fullfill promise as soon as a message begins validation
parent
bfc96c2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
gossip_tracer.go
gossip_tracer.go
+14
-9
No files found.
gossip_tracer.go
View file @
42cb3f98
...
...
@@ -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
)
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment