From 00fc286ef58d4d6927f260465d184da34f210127 Mon Sep 17 00:00:00 2001 From: Yahya Date: Sat, 6 Jul 2024 09:14:18 -0700 Subject: [PATCH 1/3] implements SendControl --- gossipsub.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gossipsub.go b/gossipsub.go index a36049f7..d430b7bf 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -1993,6 +1993,20 @@ func (gs *GossipSubRouter) WithDefaultTagTracer() Option { return WithRawTracer(gs.tagTracer) } +// SendControl dispatches the given set of control messages to the given peer. +// The control messages are sent as a single RPC, with the given (optional) messages. +// Args: +// p: the peer to send the control messages to. +// ctl: the control messages to send. +// msgs: the messages to send in the same RPC (optional). +// The control messages are piggybacked on the messages. +// Returns: +// nothing. +func (gs *GossipSubRouter) SendControl(p peer.ID, ctl *pb.ControlMessage, msgs ...*pb.Message) { + out := rpcWithControl(msgs, ctl.Ihave, ctl.Iwant, ctl.Graft, ctl.Prune) + gs.sendRPC(p, out) +} + func peerListToMap(peers []peer.ID) map[peer.ID]struct{} { pmap := make(map[peer.ID]struct{}) for _, p := range peers { From 2d4d97aa0580d21aac0838a3ba27c34b59c54d85 Mon Sep 17 00:00:00 2001 From: Yahya Date: Sat, 6 Jul 2024 09:14:48 -0700 Subject: [PATCH 2/3] lint --- gossipsub.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gossipsub.go b/gossipsub.go index d430b7bf..36b1a8ca 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -1996,12 +1996,15 @@ func (gs *GossipSubRouter) WithDefaultTagTracer() Option { // SendControl dispatches the given set of control messages to the given peer. // The control messages are sent as a single RPC, with the given (optional) messages. // Args: -// p: the peer to send the control messages to. -// ctl: the control messages to send. -// msgs: the messages to send in the same RPC (optional). -// The control messages are piggybacked on the messages. +// +// p: the peer to send the control messages to. +// ctl: the control messages to send. +// msgs: the messages to send in the same RPC (optional). +// The control messages are piggybacked on the messages. +// // Returns: -// nothing. +// +// nothing. func (gs *GossipSubRouter) SendControl(p peer.ID, ctl *pb.ControlMessage, msgs ...*pb.Message) { out := rpcWithControl(msgs, ctl.Ihave, ctl.Iwant, ctl.Graft, ctl.Prune) gs.sendRPC(p, out) From 35c385bc3edc9f4690c583439fa594c89d952f98 Mon Sep 17 00:00:00 2001 From: Yahya <19204398+yhassanzadeh13@users.noreply.github.com> Date: Fri, 18 Oct 2024 08:00:29 -0700 Subject: [PATCH 3/3] fixes compile errors --- gossipsub.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gossipsub.go b/gossipsub.go index 0a7fc194..222c71ae 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -2134,8 +2134,8 @@ func (gs *GossipSubRouter) WithDefaultTagTracer() Option { // // nothing. func (gs *GossipSubRouter) SendControl(p peer.ID, ctl *pb.ControlMessage, msgs ...*pb.Message) { - out := rpcWithControl(msgs, ctl.Ihave, ctl.Iwant, ctl.Graft, ctl.Prune) - gs.sendRPC(p, out) + out := rpcWithControl(msgs, ctl.Ihave, ctl.Iwant, ctl.Graft, ctl.Prune, ctl.Idontwant) + gs.sendRPC(p, out, false) } func peerListToMap(peers []peer.ID) map[peer.ID]struct{} {