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-router
Commits
95d0efbe
Unverified
Commit
95d0efbe
authored
Feb 05, 2020
by
Steven Allen
Committed by
GitHub
Feb 05, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #54 from libp2p/fix/ignore-bad-peers
fix: ignore bad peers when fetching the latest value
parents
eebeec43
6a6dbc43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
15 deletions
+13
-15
pubsub.go
pubsub.go
+13
-15
No files found.
pubsub.go
View file @
95d0efbe
...
...
@@ -478,7 +478,7 @@ func (p *PubsubValueStore) handleSubscription(ctx context.Context, ti *topicInfo
case
<-
ctx
.
Done
()
:
return
default
:
log
.
Errorf
(
"PubsubPeerJoin: error interacting with new peer"
,
err
)
log
.
Errorf
(
"PubsubPeerJoin: error interacting with new peer
: %s
"
,
err
)
}
}
}
...
...
@@ -524,15 +524,7 @@ func (p *PubsubValueStore) handleNewMsgs(ctx context.Context, sub *pubsub.Subscr
}
func
(
p
*
PubsubValueStore
)
handleNewPeer
(
ctx
context
.
Context
,
peerEvtHandler
*
pubsub
.
TopicEventHandler
,
key
string
)
([]
byte
,
error
)
{
select
{
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
default
:
}
var
pid
peer
.
ID
for
{
for
ctx
.
Err
()
==
nil
{
peerEvt
,
err
:=
peerEvtHandler
.
NextPeerEvent
(
ctx
)
if
err
!=
nil
{
if
err
!=
context
.
Canceled
{
...
...
@@ -540,13 +532,19 @@ func (p *PubsubValueStore) handleNewPeer(ctx context.Context, peerEvtHandler *pu
}
return
nil
,
err
}
if
peerEvt
.
Type
==
pubsub
.
PeerJoin
{
pid
=
peerEvt
.
Peer
break
if
peerEvt
.
Type
!=
pubsub
.
PeerJoin
{
continue
}
}
return
p
.
fetch
.
Fetch
(
ctx
,
pid
,
key
)
pid
:=
peerEvt
.
Peer
value
,
err
:=
p
.
fetch
.
Fetch
(
ctx
,
pid
,
key
)
if
err
==
nil
{
return
value
,
nil
}
log
.
Debugf
(
"failed to fetch latest pubsub value for key '%s' from peer '%s': %s"
,
key
,
pid
,
err
)
}
return
nil
,
ctx
.
Err
()
}
func
(
p
*
PubsubValueStore
)
notifyWatchers
(
key
string
,
data
[]
byte
)
{
...
...
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