channels

package
v0.33.33 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: AGPL-3.0 Imports: 6 Imported by: 9

Documentation

Index

Constants

View Source
const (

	// Channels used for testing
	TestNetworkChannel = Channel("test-network")
	TestMetricsChannel = Channel("test-metrics")

	// Channels for consensus protocols
	ConsensusCommittee     = Channel("consensus-committee")
	ConsensusClusterPrefix = "consensus-cluster" // dynamic channel, use ConsensusCluster function

	// Channels for protocols actively synchronizing state across nodes
	SyncCommittee     = Channel("sync-committee")
	SyncClusterPrefix = "sync-cluster" // dynamic channel, use SyncCluster function

	// Channels for dkg communication
	DKGCommittee = "dkg-committee"

	// Channels for actively pushing entities to subscribers
	PushTransactions = Channel("push-transactions")
	PushGuarantees   = Channel("push-guarantees")
	PushBlocks       = Channel("push-blocks")
	PushReceipts     = Channel("push-receipts")
	PushApprovals    = Channel("push-approvals")

	// Channels for actively requesting missing entities
	RequestCollections       = Channel("request-collections")
	RequestChunks            = Channel("request-chunks")
	RequestReceiptsByBlockID = Channel("request-receipts-by-block-id")
	RequestApprovalsByChunk  = Channel("request-approvals-by-chunk")

	// Channel aliases to make the code more readable / more robust to errors
	ReceiveTransactions = PushTransactions
	ReceiveGuarantees   = PushGuarantees
	ReceiveBlocks       = PushBlocks
	ReceiveReceipts     = PushReceipts
	ReceiveApprovals    = PushApprovals

	ProvideCollections       = RequestCollections
	ProvideChunks            = RequestChunks
	ProvideReceiptsByBlockID = RequestReceiptsByBlockID
	ProvideApprovalsByChunk  = RequestApprovalsByChunk

	// Public network channels
	PublicPushBlocks           = Channel("public-push-blocks")
	PublicReceiveBlocks        = PublicPushBlocks
	PublicSyncCommittee        = Channel("public-sync-committee")
	PublicExecutionDataService = Channel("public-execution-data-service")

	// Execution data service
	ExecutionDataService = Channel("execution-data-service")
)

channels

Variables

This section is empty.

Functions

func ChannelExists

func ChannelExists(channel Channel) bool

ChannelExists returns true if the channel exists.

func ClusterChannelPrefix

func ClusterChannelPrefix(clusterChannel Channel) (string, bool)

ClusterChannelPrefix returns the cluster channel prefix and true if clusterChannel exists inclusterChannelPrefixRoleMap

func ClusterChannelRoles

func ClusterChannelRoles(clusterChannel Channel) flow.RoleList

ClusterChannelRoles returns the list of roles that are involved in the given cluster-based channel.

func IsClusterChannel

func IsClusterChannel(channel Channel) bool

IsClusterChannel returns true if channel is cluster-based. Currently, only collection nodes are involved in a cluster-based channels.

func IsInvalidTopicErr added in v0.31.0

func IsInvalidTopicErr(err error) bool

IsInvalidTopicErr returns true if an error is InvalidTopicErr

func IsPublicChannel added in v0.27.3

func IsPublicChannel(channel Channel) bool

IsPublicChannel returns true if channel is in the public channels list

func IsUnknownClusterIDErr added in v0.31.0

func IsUnknownClusterIDErr(err error) bool

IsUnknownClusterIDErr returns true if an error is UnknownClusterIDErr

func IsValidFlowChannel added in v0.30.0

func IsValidFlowChannel(channel Channel) error

IsValidFlowChannel ensures the channel is a valid Flow network channel. All errors returned from this function can be considered benign.

func IsValidFlowClusterTopic added in v0.31.0

func IsValidFlowClusterTopic(topic Topic, activeClusterIDS flow.ChainIDList) error

IsValidFlowClusterTopic ensures the topic is a valid Flow network topic and ensures the cluster ID part of the Topic is equal to one of the provided active cluster IDs. All errors returned from this function can be considered benign. Expected errors: - InvalidTopicErr if the topic is not a valid Flow topic or the cluster ID cannot be derived from the topic. - UnknownClusterIDErr if the cluster ID from the topic is not in the activeClusterIDS list.

func IsValidNonClusterFlowTopic added in v0.31.0

func IsValidNonClusterFlowTopic(topic Topic, expectedSporkID flow.Identifier) error

IsValidNonClusterFlowTopic ensures the topic is a valid Flow network topic and ensures the sporkID part of the Topic is equal to the current network sporkID. Expected errors: - InvalidTopicErr if the topic is not a if the topic is not a valid topic for the given spork.

func RolesByChannel

func RolesByChannel(channel Channel) (flow.RoleList, bool)

RolesByChannel returns list of flow roles involved in the channel. If the given channel is a public channel, the returned list will contain all roles.

Types

type Channel

type Channel string

Channel specifies a virtual and isolated communication medium. Nodes subscribed to the same channel can disseminate epidemic messages among each other, i.e: multicast and publish.

func ChannelFromTopic

func ChannelFromTopic(topic Topic) (Channel, bool)

func ConsensusCluster

func ConsensusCluster(clusterID flow.ChainID) Channel

ConsensusCluster returns a dynamic cluster consensus channel based on the chain ID of the cluster in question.

func SyncCluster

func SyncCluster(clusterID flow.ChainID) Channel

SyncCluster returns a dynamic cluster sync channel based on the chain ID of the cluster in question.

func (Channel) String

func (c Channel) String() string

type ChannelList

type ChannelList []Channel

func Channels

func Channels() ChannelList

Channels returns all channels that nodes of any role have subscribed to (except cluster-based channels).

func ChannelsByRole

func ChannelsByRole(role flow.Role) ChannelList

ChannelsByRole returns a list of all channels the role subscribes to (except cluster-based channels and public channels).

func PublicChannels

func PublicChannels() ChannelList

PublicChannels returns all channels that are used on the public network.

func UniqueChannels

func UniqueChannels(channels ChannelList) ChannelList

UniqueChannels returns list of non-cluster channels with a unique RoleList accompanied with the list of all cluster channels. e.g. if channel X and Y both are non-cluster channels and have role IDs [A,B,C] then only one of them will be in the returned list.

func (ChannelList) Contains

func (cl ChannelList) Contains(channel Channel) bool

Contains returns true if the ChannelList contains the given channel.

func (ChannelList) ExcludeChannels added in v0.28.0

func (cl ChannelList) ExcludeChannels(other ChannelList) ChannelList

ExcludeChannels returns list of channels that are in the ChannelList but not in the other list.

func (ChannelList) ExcludePattern added in v0.28.0

func (cl ChannelList) ExcludePattern(regexp *regexp.Regexp) ChannelList

ExcludePattern returns a new ChannelList excluding the Channels that satisfy the given predicate.

func (ChannelList) ID

func (cl ChannelList) ID() flow.Identifier

ID returns hash of the content of ChannelList. It first sorts the ChannelList and then takes its hash value.

func (ChannelList) Len

func (cl ChannelList) Len() int

Len returns length of the ChannelList in the number of stored Channels. It satisfies the sort.Interface making the ChannelList sortable.

func (ChannelList) Less

func (cl ChannelList) Less(i, j int) bool

Less returns true if element i in the ChannelList is less than j based on the numerical value of its Channel. Otherwise it returns true. It satisfies the sort.Interface making the ChannelList sortable.

func (ChannelList) String added in v0.28.0

func (cl ChannelList) String() []string

func (ChannelList) Swap

func (cl ChannelList) Swap(i, j int)

Swap swaps the element i and j in the ChannelList. It satisfies the sort.Interface making the ChannelList sortable.

type InvalidTopicErr added in v0.31.0

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

InvalidTopicErr error wrapper that indicates an error when checking if a Topic is a valid Flow Topic.

func NewInvalidTopicErr added in v0.31.0

func NewInvalidTopicErr(topic Topic, err error) InvalidTopicErr

NewInvalidTopicErr returns a new ErrMalformedTopic

func (InvalidTopicErr) Error added in v0.31.0

func (e InvalidTopicErr) Error() string

type Topic

type Topic string

Topic is the internal type of Libp2p which corresponds to the Channel in the network level. It is a virtual medium enabling nodes to subscribe and communicate over epidemic dissemination.

func TopicFromChannel

func TopicFromChannel(channel Channel, rootBlockID flow.Identifier) Topic

TopicFromChannel returns the unique LibP2P topic form the channel. The channel is made up of name string suffixed with root block id. The root block id is used to prevent cross talks between nodes on different sporks.

func TopicsFromChannels added in v0.28.0

func TopicsFromChannels(channels ChannelList, rootBlockID flow.Identifier) []Topic

TopicsFromChannels returns the unique LibP2P topics form the channels.

func (Topic) String

func (t Topic) String() string

type UnknownClusterIDErr added in v0.31.0

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

UnknownClusterIDErr error wrapper that indicates an invalid topic with an unknown cluster ID prefix.

func NewUnknownClusterIdErr added in v0.31.0

func NewUnknownClusterIdErr(clusterId flow.ChainID, activeClusterIds flow.ChainIDList) UnknownClusterIDErr

NewUnknownClusterIdErr returns a new UnknownClusterIDErr

func (UnknownClusterIDErr) Error added in v0.31.0

func (e UnknownClusterIDErr) Error() string

Jump to

Keyboard shortcuts

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