floodsub

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FloodSubID = protocol.ID("bifrost/floodsub/1")
)

Variables

View Source
var (
	HeartbeatInitialDelay = 100 * time.Millisecond
	HeartbeatInterval     = 1 * time.Second
	SubFanoutTTL          = 60 * time.Second
)

Functions

func NewFloodSub

func NewFloodSub(
	ctx context.Context,
	le *logrus.Entry,
	handler pubsub.PubSubHandler,
	cc *Config,
) (pubsub.PubSub, error)

NewFloodSub constructs a new FloodSub PubSub router.

Types

type Config

type Config struct {
	// PublishHashType is the hash type to use when signing published messages.
	// Defaults to sha256
	PublishHashType      hash.HashType `` /* 128-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
	XXX_unrecognized     []byte        `json:"-"`
	XXX_sizecache        int32         `json:"-"`
}

Config configures the floodsub router.

func (*Config) Descriptor

func (*Config) Descriptor() ([]byte, []int)

func (*Config) GetPublishHashType

func (m *Config) GetPublishHashType() hash.HashType

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (m *Config) Reset()

func (*Config) String

func (m *Config) String() string

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

func (*Config) XXX_DiscardUnknown

func (m *Config) XXX_DiscardUnknown()

func (*Config) XXX_Marshal

func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Config) XXX_Merge

func (m *Config) XXX_Merge(src proto.Message)

func (*Config) XXX_Size

func (m *Config) XXX_Size() int

func (*Config) XXX_Unmarshal

func (m *Config) XXX_Unmarshal(b []byte) error

type FloodSub

type FloodSub struct {
	// contains filtered or unexported fields
}

FloodSub implements the FloodSub router.

TODO bind to a specific peer

func (*FloodSub) AddPeerStream

func (m *FloodSub) AddPeerStream(
	tpl pubsub.PeerLinkTuple,
	initiator bool,
	mstrm link.MountedStream,
)

AddPeerStream adds a negotiated peer stream. The pubsub should communicate over the stream.

func (*FloodSub) AddSubscription

func (m *FloodSub) AddSubscription(ctx context.Context, privKey crypto.PrivKey, channelID string) (pubsub.Subscription, error)

AddSubscription adds a channel subscription, returning a subscription handle.

func (*FloodSub) Close

func (m *FloodSub) Close()

Close closes the pubsub.

func (*FloodSub) Execute

func (m *FloodSub) Execute(ctx context.Context) error

Execute executes the PubSub routines.

func (*FloodSub) Publish

func (m *FloodSub) Publish(
	ctx context.Context,
	channelID string,
	privKey crypto.PrivKey,
	data []byte,
) error

Publish writes to the channel with a private key.

type Packet

type Packet struct {
	// Subscriptions contains any new subscription changes.
	Subscriptions []*SubscriptionOpts `protobuf:"bytes,1,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
	// Publish contains messages we are publishing.
	Publish              []*peer.SignedMsg `protobuf:"bytes,2,rep,name=publish,proto3" json:"publish,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

Packet is the floodsub packet.

func (*Packet) Descriptor

func (*Packet) Descriptor() ([]byte, []int)

func (*Packet) GetPublish

func (m *Packet) GetPublish() []*peer.SignedMsg

func (*Packet) GetSubscriptions

func (m *Packet) GetSubscriptions() []*SubscriptionOpts

func (*Packet) ProtoMessage

func (*Packet) ProtoMessage()

func (*Packet) Reset

func (m *Packet) Reset()

func (*Packet) String

func (m *Packet) String() string

func (*Packet) XXX_DiscardUnknown

func (m *Packet) XXX_DiscardUnknown()

func (*Packet) XXX_Marshal

func (m *Packet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Packet) XXX_Merge

func (m *Packet) XXX_Merge(src proto.Message)

func (*Packet) XXX_Size

func (m *Packet) XXX_Size() int

func (*Packet) XXX_Unmarshal

func (m *Packet) XXX_Unmarshal(b []byte) error

type SubscriptionOpts

type SubscriptionOpts struct {
	// Subscribe indicates if we are subscribing to this channel ID.
	Subscribe bool `protobuf:"varint,1,opt,name=subscribe,proto3" json:"subscribe,omitempty"`
	// ChannelId is the channel to subscribe to.
	ChannelId            string   `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

SubscriptionOpts are subscription options.

func (*SubscriptionOpts) Descriptor

func (*SubscriptionOpts) Descriptor() ([]byte, []int)

func (*SubscriptionOpts) GetChannelId

func (m *SubscriptionOpts) GetChannelId() string

func (*SubscriptionOpts) GetSubscribe

func (m *SubscriptionOpts) GetSubscribe() bool

func (*SubscriptionOpts) ProtoMessage

func (*SubscriptionOpts) ProtoMessage()

func (*SubscriptionOpts) Reset

func (m *SubscriptionOpts) Reset()

func (*SubscriptionOpts) String

func (m *SubscriptionOpts) String() string

func (*SubscriptionOpts) XXX_DiscardUnknown

func (m *SubscriptionOpts) XXX_DiscardUnknown()

func (*SubscriptionOpts) XXX_Marshal

func (m *SubscriptionOpts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SubscriptionOpts) XXX_Merge

func (m *SubscriptionOpts) XXX_Merge(src proto.Message)

func (*SubscriptionOpts) XXX_Size

func (m *SubscriptionOpts) XXX_Size() int

func (*SubscriptionOpts) XXX_Unmarshal

func (m *SubscriptionOpts) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL