floodsub

package
v0.36.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

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

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 `protobuf:"varint,1,opt,name=publish_hash_type,json=publishHashType,proto3" json:"publishHashType,omitempty"`
	// contains filtered or unexported fields
}

Config configures the floodsub router.

func (*Config) CloneMessageVT added in v0.15.6

func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Config) CloneVT added in v0.8.3

func (m *Config) CloneVT() *Config

func (*Config) EqualMessageVT added in v0.15.6

func (this *Config) EqualMessageVT(thatMsg any) bool

func (*Config) EqualVT added in v0.3.0

func (this *Config) EqualVT(that *Config) bool

func (*Config) GetPublishHashType

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

func (*Config) MarshalJSON added in v0.29.0

func (x *Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config to JSON.

func (*Config) MarshalProtoJSON added in v0.29.0

func (x *Config) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config message to JSON.

func (*Config) MarshalProtoText added in v0.29.2

func (x *Config) MarshalProtoText() string

func (*Config) MarshalToSizedBufferVT added in v0.2.0

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT added in v0.2.0

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT added in v0.2.0

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SizeVT added in v0.2.0

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalJSON added in v0.29.0

func (x *Config) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config from JSON.

func (*Config) UnmarshalProtoJSON added in v0.29.0

func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config message from JSON.

func (*Config) UnmarshalVT added in v0.2.0

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

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"`
	// contains filtered or unexported fields
}

Packet is the floodsub packet.

func (*Packet) CloneMessageVT added in v0.15.6

func (m *Packet) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Packet) CloneVT added in v0.8.3

func (m *Packet) CloneVT() *Packet

func (*Packet) EqualMessageVT added in v0.15.6

func (this *Packet) EqualMessageVT(thatMsg any) bool

func (*Packet) EqualVT added in v0.3.0

func (this *Packet) EqualVT(that *Packet) bool

func (*Packet) GetPublish

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

func (*Packet) GetSubscriptions

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

func (*Packet) MarshalJSON added in v0.29.0

func (x *Packet) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Packet to JSON.

func (*Packet) MarshalProtoJSON added in v0.29.0

func (x *Packet) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Packet message to JSON.

func (*Packet) MarshalProtoText added in v0.29.2

func (x *Packet) MarshalProtoText() string

func (*Packet) MarshalToSizedBufferVT added in v0.2.0

func (m *Packet) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Packet) MarshalToVT added in v0.2.0

func (m *Packet) MarshalToVT(dAtA []byte) (int, error)

func (*Packet) MarshalVT added in v0.2.0

func (m *Packet) MarshalVT() (dAtA []byte, err error)

func (*Packet) ProtoMessage

func (*Packet) ProtoMessage()

func (*Packet) Reset

func (x *Packet) Reset()

func (*Packet) SizeVT added in v0.2.0

func (m *Packet) SizeVT() (n int)

func (*Packet) String

func (x *Packet) String() string

func (*Packet) UnmarshalJSON added in v0.29.0

func (x *Packet) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Packet from JSON.

func (*Packet) UnmarshalProtoJSON added in v0.29.0

func (x *Packet) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Packet message from JSON.

func (*Packet) UnmarshalVT added in v0.2.0

func (m *Packet) UnmarshalVT(dAtA []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:"channelId,omitempty"`
	// contains filtered or unexported fields
}

SubscriptionOpts are subscription options.

func (*SubscriptionOpts) CloneMessageVT added in v0.15.6

func (m *SubscriptionOpts) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*SubscriptionOpts) CloneVT added in v0.8.3

func (m *SubscriptionOpts) CloneVT() *SubscriptionOpts

func (*SubscriptionOpts) EqualMessageVT added in v0.15.6

func (this *SubscriptionOpts) EqualMessageVT(thatMsg any) bool

func (*SubscriptionOpts) EqualVT added in v0.3.0

func (this *SubscriptionOpts) EqualVT(that *SubscriptionOpts) bool

func (*SubscriptionOpts) GetChannelId

func (x *SubscriptionOpts) GetChannelId() string

func (*SubscriptionOpts) GetSubscribe

func (x *SubscriptionOpts) GetSubscribe() bool

func (*SubscriptionOpts) MarshalJSON added in v0.29.0

func (x *SubscriptionOpts) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SubscriptionOpts to JSON.

func (*SubscriptionOpts) MarshalProtoJSON added in v0.29.0

func (x *SubscriptionOpts) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SubscriptionOpts message to JSON.

func (*SubscriptionOpts) MarshalProtoText added in v0.29.2

func (x *SubscriptionOpts) MarshalProtoText() string

func (*SubscriptionOpts) MarshalToSizedBufferVT added in v0.2.0

func (m *SubscriptionOpts) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SubscriptionOpts) MarshalToVT added in v0.2.0

func (m *SubscriptionOpts) MarshalToVT(dAtA []byte) (int, error)

func (*SubscriptionOpts) MarshalVT added in v0.2.0

func (m *SubscriptionOpts) MarshalVT() (dAtA []byte, err error)

func (*SubscriptionOpts) ProtoMessage

func (*SubscriptionOpts) ProtoMessage()

func (*SubscriptionOpts) Reset

func (x *SubscriptionOpts) Reset()

func (*SubscriptionOpts) SizeVT added in v0.2.0

func (m *SubscriptionOpts) SizeVT() (n int)

func (*SubscriptionOpts) String

func (x *SubscriptionOpts) String() string

func (*SubscriptionOpts) UnmarshalJSON added in v0.29.0

func (x *SubscriptionOpts) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SubscriptionOpts from JSON.

func (*SubscriptionOpts) UnmarshalProtoJSON added in v0.29.0

func (x *SubscriptionOpts) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SubscriptionOpts message from JSON.

func (*SubscriptionOpts) UnmarshalVT added in v0.2.0

func (m *SubscriptionOpts) UnmarshalVT(dAtA []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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