msgbus

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 2 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultSubscriber

type DefaultSubscriber struct{}

DefaultSubscriber 默认消息订阅者

func (DefaultSubscriber) OnMessage

func (DefaultSubscriber) OnMessage(*Message)

OnMessage 接收广播的消息进行处理 @param *Message

func (DefaultSubscriber) OnQuit

func (DefaultSubscriber) OnQuit()

OnQuit 关闭消息通道

type Message

type Message struct {
	Topic   Topic
	Payload interface{}
}

Message 消息对象

type MessageBus

type MessageBus interface {
	// A subscriber register on s specific topic.
	// When a message on this topic is published, the subscriber's OnMessage() is called.
	Register(topic Topic, sub Subscriber)
	// UnRegister unregister the subscriber from message bus.
	UnRegister(topic Topic, sub Subscriber)
	// Used to publish a message on this message bus to notify subscribers.
	Publish(topic Topic, payload interface{})
	// Used to publish a message on this message bus to notify subscribers.
	// Safe mode, make sure the subscriber's OnMessage() is called with the order of a message on this topic is published.
	PublishSafe(topic Topic, payload interface{})
	// Used to publish a message on this message bus to notify subscribers.
	// Sync mod, make sure all messages  are completed sequentially.
	PublishSync(topic Topic, payload interface{})
	// Close the message bus, all publishes are ignored.
	Close()
}

MessageBus provides a pub-sub interface for cross-module communication

func NewMessageBus

func NewMessageBus() MessageBus

NewMessageBus 构造一个MessageBus对象 @return MessageBus

type Subscriber

type Subscriber interface {
	// When a message with topic A is published on the message bus,
	// all the subscribers's OnMessage() methods of topic A are called.
	OnMessage(*Message)

	// When the message bus is shutting down,
	OnQuit()
}

Subscriber should implement these methods,

type Topic

type Topic int

nolint Topic 消息主题

const (
	Invalid Topic = iota
	ProposedBlock
	VerifyBlock
	VerifyResult
	CommitBlock
	ProposeState
	TxPoolSignal
	BlockInfo
	ContractEventInfo

	SendConsensusMsg
	RecvConsensusMsg
	SendSyncBlockMsg
	RecvSyncBlockMsg
	SendTxPoolMsg
	RecvTxPoolMsg

	BuildProposal

	ChainConfig

	CertManageCertsDelete
	CertManageCertsFreeze
	CertManageCertsUnfreeze
	CertManageCertsRevoke
	CertManageCertsAliasUpdate
	CertManageCertsAliasDelete

	PubkeyManageAdd
	PubkeyManageDelete

	// For Consistent Engine
	SendConsistentMsg
	RecvConsistentMsg

	// For new transactions signal for maxbft
	ProposeBlock

	MaxbftEpochConf

	// solve random tx
	RwSetVerifyFailTxs

	// used to cache the deduction account address to avoid reading the database every time
	PayerConfig
)

消息主题类型

const (
	// For blacklistTxId
	BlacklistTxIdAdd Topic = iota + 100
	BlacklistTxIdDel

	// For BlacklistStateKey
	BlacklistStateKeyAdd
	BlacklistStateKeyDel
)

合约事件类型

func (Topic) String

func (i Topic) String() string

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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