Versions in this module Expand all Collapse all v0 v0.0.7 Sep 22, 2021 Changes in this version + const DefaultAppMsgCacheMaxSize + const DefaultAppMsgCacheTimeout + const DefaultAppMsgStationsLength + const DefaultDegreeDesired + const DefaultDegreeHigh + const DefaultDegreeLow + const DefaultFanOutSize + const DefaultFanOutTimeout + const DefaultGossipBatchSendApplicationLength + const DefaultGossipInterval + const DefaultGossipSize + const DefaultMaxSendApplicationMsgSize + const DefaultMetadataCacheMaxSize + const DefaultMetadataCacheTimeout + const ProtocolIDTemplate + var ErrDiffHost = errors.New("different host") + var ErrNilHost = errors.New("nil host") + func CreatePubSubMsgPayload(appMsgs []*pb.ApplicationMsg, spreadMsg *pb.IHaveOrWant, topicMsg *pb.TopicMsg, ...) ([]byte, error) + func GetMsgKey(sender string, seq uint64) string + func GetPubSubMsgWithPayload(payload []byte) (*pb.PubsubMsg, error) + type ChainPubSub struct + func NewChainPubSub(chainId string, logger api.Logger, opts ...Option) *ChainPubSub + func (p *ChainPubSub) AllMetadataOnlyPeers() []peer.ID + func (p *ChainPubSub) AttachHost(h host.Host) error + func (p *ChainPubSub) HostNotifiee() host.Notifiee + func (p *ChainPubSub) ID() peer.ID + func (p *ChainPubSub) ProtocolID() protocol.ID + func (p *ChainPubSub) ProtocolMsgHandler() handler.MsgPayloadHandler + func (p *ChainPubSub) Publish(topic string, msg []byte) + func (p *ChainPubSub) RemoveBlackPeer(pid peer.ID) + func (p *ChainPubSub) SetBlackPeer(pid peer.ID) + func (p *ChainPubSub) Stop() error + func (p *ChainPubSub) Subscribe(topic string, msgHandler handler.SubMsgHandler) + func (p *ChainPubSub) Unsubscribe(topic string) + type MsgBasket struct + func NewMsgBasket(pubSub *ChainPubSub) *MsgBasket + func (mb *MsgBasket) Cancel() + func (mb *MsgBasket) HeartBeat() + func (mb *MsgBasket) PutApplicationMsg(msg ...*pb.ApplicationMsg) + func (mb *MsgBasket) SendCutOff(topic string, pid peer.ID) + func (mb *MsgBasket) SendJoinUp(topic string, pid peer.ID) + func (mb *MsgBasket) SubOrUnSubTopic(topic string, subOrUnSub bool) + type MsgCache struct + func NewMsgCache(applicationMsgDuration time.Duration, metadataMsgDuration time.Duration, ...) *MsgCache + func (c *MsgCache) AllApplicationMsg() []*pb.ApplicationMsg + func (c *MsgCache) AllMsgMetadata() []*pb.MsgMetadata + func (c *MsgCache) Put(msg *pb.ApplicationMsg) bool + func (c *MsgCache) PutIfNoExists(msg *pb.ApplicationMsg) bool + type Option func(pubsub *ChainPubSub) + func WithAppMsgCacheMaxSize(size int) Option + func WithAppMsgCacheTimeout(timeout time.Duration) Option + func WithDegreeDesired(desired int32) Option + func WithDegreeHigh(high int32) Option + func WithDegreeLow(low int32) Option + func WithFanOutSize(size int32) Option + func WithFanOutTimeout(timeout time.Duration) Option + func WithGossipInterval(interval time.Duration) Option + func WithGossipSize(size int) Option + func WithMetadataCacheMaxSize(size int) Option + func WithMetadataCacheTimeout(timeout time.Duration) Option + func WithPubSubMessageMaxSize(size int32) Option + type PeerState interface + AllMetadataPeerId func() []peer.ID + CacheMsg func(applicationMsg *pb.ApplicationMsg) + GetAllMsgMetadata func() []*pb.MsgMetadata + GetChainPubSub func() *ChainPubSub + GetMessageListWithMetadataList func(metadataList []*pb.MsgMetadata) []*pb.ApplicationMsg + GetTopics func() []string + ID func() peer.ID + IHaveMessage func() []*pb.MsgMetadata + IWantMessage func(peerHaveMessage []*pb.MsgMetadata) []*pb.MsgMetadata + IsPeerReceivedMsg func(pid peer.ID, applicationMsg *pb.ApplicationMsg) bool + IsSubscribed func(topic string) bool + RecordPeerReceivedMsg func(pid peer.ID, meta *pb.MsgMetadata) bool + Subscribe func(topic string, handler handler.SubMsgHandler) error + Unsubscribe func(topic string) + type TypeOfPeering int + const FanOutTypeOfPeering + const FullMsgTypeOfPeering + const MetadataOnlyTypeOfPeering + const UnknownTypeOfPeering