raft

package module
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: 40 Imported by: 0

Documentation

Overview

Package raft is the raft consensus for ChainMaker

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultChanCap is the default chan cap in ConsensusRaftImpl
	DefaultChanCap = 1000

	// RAFTAddtionalDataKey is the key for QC
	RAFTAddtionalDataKey = "RAFTAddtionalDataKey"

	// AdditionalDataKey for additional data
	AdditionalDataKey = "AddtionalDataKey"

	// ErrNotConsensusNode is an error tells that the current node
	// is a sync node and it not support consensus state interface
	ErrNotConsensusNode = errors.New("the node is not a consensus node")
)

Functions

func InitLWS

func InitLWS(config *config.ConsensusConfig, waldir string) (lwsInstance *lws.Lws,
	walWriteMode wal_service.WalWriteMode, err error)

InitLWS for wal

func VerifyBlockSignatures

func VerifyBlockSignatures(block *common.Block) error

VerifyBlockSignatures verifies whether the signatures in block is qulified with the consensus algorithm. It should return nil error when verify successfully, and return corresponding error when failed. @Description: VerifyBlockSignatures @receiver consensus @param block *common.Block @return error

Types

type AdditionalData

type AdditionalData struct {
	Signature []byte
}

AdditionalData contains consensus specified data to be store in block

type ConsensusRaftImpl

type ConsensusRaftImpl struct {
	sync.RWMutex

	// the nodeId of etcd-raft
	Id uint64

	// current proposer's nodeId
	Proposer string
	// contains filtered or unexported fields
}

ConsensusRaftImpl is the implementation of Raft algorithm and it implements the ConsensusEngine interface.

func New

New creates a raft consensus instance @Description: return ConsensusRaftImpl @receiver consensus @param config @return *ConsensusRaftImpl @return error

func (*ConsensusRaftImpl) AsyncWalSave

func (consensus *ConsensusRaftImpl) AsyncWalSave()

AsyncWalSave write wal asynchronously

func (*ConsensusRaftImpl) Close added in v3.0.1

func (consensus *ConsensusRaftImpl) Close() error

Close the consensus-engine

func (*ConsensusRaftImpl) GetAllNodeInfos

func (consensus *ConsensusRaftImpl) GetAllNodeInfos() []consensuspb.ConsensusNodeInfo

GetAllNodeInfos returns all consensus nodes' information

func (*ConsensusRaftImpl) GetConsensusStateJSON

func (consensus *ConsensusRaftImpl) GetConsensusStateJSON() ([]byte, error)

GetConsensusStateJSON returns the node status

func (*ConsensusRaftImpl) GetConsensusType

func (consensus *ConsensusRaftImpl) GetConsensusType() consensuspb.ConsensusType

GetConsensusType return consensus type raft @Description: GetConsensusType @receiver consensus @param nil @return ConsensusType consensuspb.ConsensusType

func (*ConsensusRaftImpl) GetLastHeight

func (consensus *ConsensusRaftImpl) GetLastHeight() uint64

GetLastHeight returns last height in ConsensusRaftImpl

func (*ConsensusRaftImpl) GetValidators

func (consensus *ConsensusRaftImpl) GetValidators() ([]string, error)

GetValidators returns all validators for ConsensusRaftImpl

func (*ConsensusRaftImpl) IsValidator added in v3.0.1

func (consensus *ConsensusRaftImpl) IsValidator() bool

IsValidator checks that the current node is a consensus node or not

func (*ConsensusRaftImpl) NodeReady

func (consensus *ConsensusRaftImpl) NodeReady(ready etcdraft.Ready)

NodeReady process ready msg from etcd-raft

func (*ConsensusRaftImpl) OnMessage

func (consensus *ConsensusRaftImpl) OnMessage(message *msgbus.Message)

OnMessage receives messages from msgbus @Description: msgbus @receiver consensus @param message @return nil

func (*ConsensusRaftImpl) OnQuit

func (consensus *ConsensusRaftImpl) OnQuit()

OnQuit is on quit for msgbus @Description: OnQuit @receiver consensus @param nil @return nil

func (*ConsensusRaftImpl) ProposeBlock

func (consensus *ConsensusRaftImpl) ProposeBlock(proposalBlock *consensuspb.ProposalBlock)

ProposeBlock process proposed block from core engine

func (*ConsensusRaftImpl) Start

func (consensus *ConsensusRaftImpl) Start() error

Start starts the raft instance @Description: start engine @receiver consensus @param nil @return error

func (*ConsensusRaftImpl) Stop

func (consensus *ConsensusRaftImpl) Stop() error

Stop stops the raft instance, we have to do nothing in here because we can't stopped by the blockChain directly, we should tell etcd-raft that the current node was removed by some configuration changing before exit

func (*ConsensusRaftImpl) Verify

func (consensus *ConsensusRaftImpl) Verify(
	consensusType consensuspb.ConsensusType,
	chainConfig *config.ChainConfig) error

Verify implements interface of struct Verifier, This interface is used to verify the validity of parameters, it executes before consensus. @Description: Verify @receiver consensus @param nil @return nil

type ConsensusStatus

type ConsensusStatus struct {
	Height          uint64
	CommittedHeight uint64
	Proposer        string
	Validators      []string
}

ConsensusStatus describe the current status of the consensus cluster

type Logger

type Logger struct {
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

Logger implements raft.Logger interface with wraping zap.SugaredLogger

func NewLogger

func NewLogger(lg *zap.SugaredLogger) *Logger

NewLogger creates a new Logger instance

func (*Logger) Warning

func (l *Logger) Warning(v ...interface{})

Warning print warning log

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...interface{})

Warningf print warning log with format

type SnapshotArgs

type SnapshotArgs struct {
	Index       uint64
	BlockHeight uint64
	ConfChange  bool
}

SnapshotArgs is snapshot args for raft

type SnapshotHeight

type SnapshotHeight struct {
	Height uint64
}

SnapshotHeight stores block height in raft snapshot.

type WalEntry

type WalEntry struct {
	HardState        raftpb.HardState
	Entries          []raftpb.Entry
	LastSnapWalIndex uint64
}

WalEntry for lws storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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