raft

package module
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: Apache-2.0 Imports: 38 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"
)

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

	Id uint64

	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 @Description: AsyncWalSave @receiver consensus @param nil @return nil

func (*ConsensusRaftImpl) GetAllNodeInfos

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

GetAllNodeInfos get information of all raft nodes known by local node @Description: GetAllNodeInfos @receiver consensus @param nil @return AllNodeInfos []protocol.ConsensusNodeInfo

func (*ConsensusRaftImpl) GetConsensusStateJSON

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

GetConsensusStateJSON node status @Description: GetConsensusStateJSON @receiver consensus @param nil @return StatusJson []byte @return error

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 get last height in ConsensusRaftImpl @Description: GetLastHeight @receiver consensus @param nil @return lastHeight uint64

func (*ConsensusRaftImpl) GetValidators

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

GetValidators get all validators for ConsensusRaftImpl @Description: GetValidators @receiver consensus @param nil @return Validators []string

func (*ConsensusRaftImpl) NodeReady

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

NodeReady process ready msg from etcd.raft @Description: NodeReady @receiver consensus @param ready etcdraft.Ready @return nil

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 handle proposal block @Description: ProposeBlock @receiver consensus @param ready proposalBlock *consensuspb.ProposalBlock @return nil

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 @Description: stop engine @receiver consensus @param nil @return error

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 ConsensusRaftImplConfig

type ConsensusRaftImplConfig struct {
	ChainID        string
	NodeId         string
	Singer         protocol.SigningMember
	Ac             protocol.AccessControlProvider
	LedgerCache    protocol.LedgerCache
	BlockVerifier  protocol.BlockVerifier
	BlockCommitter protocol.BlockCommitter
	ChainConf      protocol.ChainConf
	MsgBus         msgbus.MessageBus
}

ConsensusRaftImplConfig contains initialization config for ConsensusRaftImpl

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
	LastUncommittedIndex 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