raft

package module
v0.0.0-...-27344ce Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 34 Imported by: 2

README

consensus-raft

介绍

hercules 链 raft 共识模块

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultChanCap = 1000

	RAFTAddtionalDataKey = "RAFTAddtionalDataKey"
)

Functions

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.

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

func (*ConsensusRaftImpl) AsyncWalSave

func (consensus *ConsensusRaftImpl) AsyncWalSave()

func (*ConsensusRaftImpl) GetConsensusStateJSON

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

func (*ConsensusRaftImpl) GetLastHeight

func (consensus *ConsensusRaftImpl) GetLastHeight() uint64

func (*ConsensusRaftImpl) GetValidators

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

func (*ConsensusRaftImpl) NodeReady

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

func (*ConsensusRaftImpl) OnMessage

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

OnMessage receives messages from msgbus

func (*ConsensusRaftImpl) OnQuit

func (consensus *ConsensusRaftImpl) OnQuit()

func (*ConsensusRaftImpl) ProposeBlock

func (consensus *ConsensusRaftImpl) ProposeBlock(block *common.Block)

func (*ConsensusRaftImpl) PurgeFile

func (consensus *ConsensusRaftImpl) PurgeFile(dirname string)

func (*ConsensusRaftImpl) Start

func (consensus *ConsensusRaftImpl) Start() error

Start starts the raft instance

func (*ConsensusRaftImpl) Stop

func (consensus *ConsensusRaftImpl) Stop() error

Start stops the raft instance

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.

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 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{})

func (*Logger) Warningf

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

type SnapshotArgs

type SnapshotArgs struct {
	Index       uint64
	BlockHeight uint64
	ConfChange  bool
}

type SnapshotHeight

type SnapshotHeight struct {
	Height uint64
}

SnapshotHeight stores block height in raft snapshot.

Jump to

Keyboard shortcuts

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