engine

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MAXBFT_LOCAL_NODE_STATUS defines local node status of the consistent engine
	MAXBFT_LOCAL_NODE_STATUS = iota

	// MAXBFT_REMOTE_NODE_STATUS defines remote node status of the consistent engine
	MAXBFT_REMOTE_NODE_STATUS
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsensusEngine

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

ConsensusEngine implements a MaxBft consensus engine

func NewEngine

func NewEngine(cfg *consensusUtils.ConsensusImplConfig,
	epochState *maxbft.GovernanceContract, hasReplayed bool) (*ConsensusEngine, error)

NewEngine create consensus engine

func (*ConsensusEngine) Data

func (e *ConsensusEngine) Data() interface{}

Data Return the status of the local node

func (*ConsensusEngine) DiscardBlocks

func (e *ConsensusEngine) DiscardBlocks(height uint64)

DiscardBlocks discards blocks in the cache of core engine module

func (*ConsensusEngine) GetConsensusStateJSON

func (e *ConsensusEngine) GetConsensusStateJSON() ([]byte, error)

GetConsensusStateJSON get consensus state

func (*ConsensusEngine) GetLastHeight

func (e *ConsensusEngine) GetLastHeight() uint64

GetLastHeight get latest consensus height

func (*ConsensusEngine) GetValidators

func (e *ConsensusEngine) GetValidators() ([]string, error)

GetValidators get validators

func (*ConsensusEngine) HandleProposal

func (e *ConsensusEngine) HandleProposal(proposal *msgcache.PendingProposal)

HandleProposal Processing proposal from msgcache component

func (*ConsensusEngine) HandleStatus

func (e *ConsensusEngine) HandleStatus()

HandleStatus Update local state with information received from other nodes

func (*ConsensusEngine) ID

func (e *ConsensusEngine) ID() string

ID Identifies the node ID in the consistent service

func (*ConsensusEngine) IsRunning

func (e *ConsensusEngine) IsRunning() bool

IsRunning Indicates whether the status broadcast service is running

func (*ConsensusEngine) OnMessage

func (e *ConsensusEngine) OnMessage(message *msgbus.Message)

OnMessage process message from msgBus

func (*ConsensusEngine) OnQuit

func (e *ConsensusEngine) OnQuit()

OnQuit quit

func (*ConsensusEngine) PreBroadcaster

func (e *ConsensusEngine) PreBroadcaster() consistent_service.Broadcast

PreBroadcaster Preprocessing of a node's broadcast message, returning data to be broadcast

func (*ConsensusEngine) Run

func (e *ConsensusEngine) Run()

Run The status broadcast service is started

func (*ConsensusEngine) Start

func (e *ConsensusEngine) Start() error

Start implement the Start function of interface StatusBroadcaster

func (*ConsensusEngine) StartEngine

func (e *ConsensusEngine) StartEngine() error

StartEngine starts the local consensus engine

func (*ConsensusEngine) Statuses

func (e *ConsensusEngine) Statuses() map[int8]consistent_service.Status

Statuses implements Statuses of the Node interface in consistent engine for the local node

func (*ConsensusEngine) Stop

func (e *ConsensusEngine) Stop() error

Stop implement the Stop function of interface StatusBroadcaster

func (*ConsensusEngine) StopEngine

func (e *ConsensusEngine) StopEngine() error

StopEngine stops the local consensus engine

func (*ConsensusEngine) SwitchEpoch

func (e *ConsensusEngine) SwitchEpoch(contract *maxbft.GovernanceContract)

SwitchEpoch fired msg to switch epoch

func (*ConsensusEngine) SwitchState

func (e *ConsensusEngine) SwitchState(contract *maxbft.GovernanceContract) error

SwitchState After the epoch switch is successful, the status of consensus engine is updated to the new epoch and the part of data of the old epoch is clear.

func (*ConsensusEngine) TimePattern

func (e *ConsensusEngine) TimePattern() interface{}

TimePattern The timing set in the consistent service

func (*ConsensusEngine) TriggerNewEpoch

func (e *ConsensusEngine) TriggerNewEpoch() error

TriggerNewEpoch Launch the new epoch 当存在连续几个块都为世代切换配置块(如:实时配置变更模式),且节点共识引擎已经启动的 情况下,在处理区块提交信息过程中使用链上的最新状态更新完引擎的各组件后,调用该方法 触发节点在新世代共识流程继续运行

func (*ConsensusEngine) Type

func (e *ConsensusEngine) Type() int8

Type Returns the type of node status

func (*ConsensusEngine) Update

func (e *ConsensusEngine) Update(remoteStatus consistent_service.Status)

Update local node status with remote node information

func (*ConsensusEngine) UpdateStatus

func (e *ConsensusEngine) UpdateStatus(status consistent_service.Status)

UpdateStatus implements UpdateStatus of the Node interface in consistent engine for the local node

func (*ConsensusEngine) Verify

func (e *ConsensusEngine) Verify(consensusType consensus.ConsensusType, chainConfig *config.ChainConfig) error

Verify Implement verification interface for configuration changes

type Decoder

type Decoder struct {
}

Decoder implements Decoder interface in consistent engine

func (*Decoder) Decode

func (d *Decoder) Decode(arg interface{}) interface{}

Decode deserialize messages for consistent engine

func (*Decoder) MsgType

func (d *Decoder) MsgType() int8

MsgType returns the consistent message type

type Event

type Event interface {
	Type() EventType
}

Event which the engine will be processed

type EventType

type EventType int

EventType event type that engine will be processed

const (
	// RestartSyncServiceEvent start the sync service
	RestartSyncServiceEvent EventType = iota
)

type RemoteNodeInfo

type RemoteNodeInfo struct {
	*RemotePeerStatus
	// contains filtered or unexported fields
}

RemoteNodeInfo implements the Node interface in consistent engine, and to describe the status of the remote nodes

func NewRemoteInfo

func NewRemoteInfo(msg *maxbft.NodeStatus, local *ConsensusEngine) *RemoteNodeInfo

NewRemoteInfo initials and returns a RemoteNodeInfo object

func (*RemoteNodeInfo) ID

func (r *RemoteNodeInfo) ID() string

ID returns the node Id of the remote node

func (*RemoteNodeInfo) Statuses

func (r *RemoteNodeInfo) Statuses() map[int8]consistent_service.Status

Statuses implements Statuses of the Node interface in consistent engine for a remote node

func (*RemoteNodeInfo) UpdateStatus

func (r *RemoteNodeInfo) UpdateStatus(status consistent_service.Status)

UpdateStatus implements UpdateStatus of the Node interface in consistent engine for a remote node

type RemotePeerStatus

type RemotePeerStatus struct {
	*maxbft.NodeStatus
	// contains filtered or unexported fields
}

RemotePeerStatus defines remote peer status, implements Status interface of the consistent engine

func NewRemotePeer

func NewRemotePeer(msg *maxbft.NodeStatus, local *ConsensusEngine) *RemotePeerStatus

NewRemotePeer initials and returns a RemotePeerStatus object

func (*RemotePeerStatus) Data

func (r *RemotePeerStatus) Data() interface{}

Data returns the status data

func (*RemotePeerStatus) Type

func (r *RemotePeerStatus) Type() int8

Type returns the remote node status of the consistent engine

func (*RemotePeerStatus) Update

func (r *RemotePeerStatus) Update(nodeStatus consistent_service.Status)

Update updates local status by the specified node status

type StartSyncService

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

StartSyncService start sync service

func NewStartSyncService

func NewStartSyncService(nodeId string, epochId uint64) *StartSyncService

NewStartSyncService init

func (*StartSyncService) Type

func (s *StartSyncService) Type() EventType

Type the event type

type Transceiver

type Transceiver struct {
	msgbus.MessageBus
	// contains filtered or unexported fields
}

Transceiver implements Message interface of the consistent engine

func NewTransceiver

func NewTransceiver(msgBus msgbus.MessageBus, receiver chan *net.NetMsg) *Transceiver

NewTransceiver initials and returns a Transceiver object

func (*Transceiver) Receive

func (t *Transceiver) Receive() interface{}

Receive consistent messages from other consensus nodes

func (*Transceiver) Send

func (t *Transceiver) Send(payload interface{})

Send sends consistent messages to other consensus nodes

func (*Transceiver) Start added in v3.0.1

func (t *Transceiver) Start() error

Start message

func (*Transceiver) Stop added in v3.0.1

func (t *Transceiver) Stop() error

Stop message

Jump to

Keyboard shortcuts

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