-
Notifications
You must be signed in to change notification settings - Fork 205
Open
Description
Description
Proposal: Introduce a new function, SendControl
, to the GossipSubRouter
that allows the application layer to send direct control messages to a peer. This feature will primarily be used to develop finer-grained testing. Flow blockchain currently uses this feature quite extensively.
Proposed Function
// SendControl dispatches the given set of control messages to the given peer.
func (gs *GossipSubRouter) SendControl(p peer.ID, ctl *pb.ControlMessage, msgs ...*pb.Message) bool {
out := rpcWithControl(msgs, ctl.Ihave, ctl.Iwant, ctl.Graft, ctl.Prune)
return gs.sendRPC(p, out)
}
Sample implementation on my forked version.
Rationale
Adding this function does not break encapsulation drastically. It is available at the router-level, meaning it is only accessible if the application layer creates a router and passes it to a pubsub instance, rather than creating a gossipsub instance directly. This ensures controlled usage and maintains the integrity of the encapsulation.
Benefits
- Enables finer-grained testing.
- Provides more control for application layer developers.
- Maintains encapsulation integrity by limiting accessibility.
I can make the PR upon a soft approval.
Metadata
Metadata
Assignees
Labels
No labels