libp2p / go-libp2p-pubsub

The PubSub implementation for go-libp2p
https://github.com/libp2p/specs/tree/master/pubsub
Other
313 stars 179 forks source link

Abstracts GossipSubRouter interface #505

Closed yhassanzadeh13 closed 1 year ago

yhassanzadeh13 commented 1 year ago

Problem Statement

Although in https://github.com/libp2p/go-libp2p-pubsub/pull/503 we introduced injectible PubSubRouter into the GossipSub, there are several places in the code that initializing a GossipSub instance with a customized PubSubRouter is failing due to the strict type assertions, e.g., example-1, example-2, and example-3.

Although the rt (router) attribute of the GossipSub is deemed as a PubSubRouter interface type, nevertheless through the initialization phase of the GossipSub the rt attribute is strictly asserted as a GossipSubRouter value type. This is a blocker for initializing GossipSub with customized wrappers around GossipSubRouter as it no longer is going to be a GossipSubRouter strict value type. Hence the initialization fails with an pubsub router is not gossipsub error.

Contributions

In order to resolve the initialization failure due to the strict type assertions with GossipSubRouter this PR introduces the following changes:

yhassanzadeh13 commented 1 year ago

Thanks @vyzo, closing this PR in the favor of https://github.com/libp2p/go-libp2p-pubsub/pull/509