From 39fc35f7cbbbb4f62308be6f676a17f85a7fbdd9 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 16 May 2020 12:57:44 +0300 Subject: [PATCH] check if already in the mesh in handleGraft to support concurrent grafting --- gossipsub.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gossipsub.go b/gossipsub.go index 27dac7c..2ef7b64 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -537,6 +537,12 @@ func (gs *GossipSubRouter) handleGraft(p peer.ID, ctl *pb.ControlMessage) []*pb. continue } + // check if it is already in the mesh; if so do nothing (we might have concurrent grafting) + _, inMesh := peers[p] + if inMesh { + continue + } + // we don't GRAFT to/from direct peers; complain loudly if this happens _, direct := gs.direct[p] if direct {