From 448f38072203e4fc4f1494cca159a7ff0dce6b1d Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 16 Feb 2018 22:01:15 +0200 Subject: [PATCH] gossipsub: router outline --- gossipsub.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 gossipsub.go diff --git a/gossipsub.go b/gossipsub.go new file mode 100644 index 0000000..46f50cf --- /dev/null +++ b/gossipsub.go @@ -0,0 +1,56 @@ +package floodsub + +import ( + "context" + + pb "github.com/libp2p/go-floodsub/pb" + + host "github.com/libp2p/go-libp2p-host" + peer "github.com/libp2p/go-libp2p-peer" + protocol "github.com/libp2p/go-libp2p-protocol" +) + +const ( + GossipSubID = protocol.ID("/meshsub/1.0.0") +) + +func NewGossipSub(ctx context.Context, h host.Host, opts ...Option) (*PubSub, error) { + rt := &GossipSubRouter{} + return NewPubSub(ctx, h, rt, opts...) +} + +type GossipSubRouter struct { + p *PubSub +} + +func (fs *GossipSubRouter) Protocols() []protocol.ID { + return []protocol.ID{GossipSubID, FloodSubID} +} + +func (fs *GossipSubRouter) Attach(p *PubSub) { + fs.p = p +} + +func (fs *GossipSubRouter) AddPeer(peer.ID, protocol.ID) { + +} + +func (fs *GossipSubRouter) RemovePeer(peer.ID) { + +} + +func (fs *GossipSubRouter) HandleRPC(rpc *RPC) { + +} + +func (fs *GossipSubRouter) Publish(from peer.ID, msg *pb.Message) { + +} + +func (fs *GossipSubRouter) Join(topic string) { + +} + +func (fs *GossipSubRouter) Leave(topic string) { + +}