quorum

package
v0.0.0-...-b124b1e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValidQC       = errors.New("target qc is empty")
	ErrNoValidParentId = errors.New("parentId is empty")
)

Functions

func NewSignToOld

func NewSignToOld(new []*protos.QuorumCertSign) []*protos.SignInfo

NewSignToOld 新的签名结构转化为老的签名结构

func NewToOldQC

func NewToOldQC(new *QuorumCertImpl) (*protos.QuorumCert, error)

NewToOldQC 将新的QC pb结构转化为老pb结构

func OldSignToNew

func OldSignToNew(storage []byte) []*protos.QuorumCertSign

OldSignToNew 老的签名结构转化为新的签名结构

Types

type ConsensusStorage

type ConsensusStorage struct {
	Justify     *protos.QuorumCert `json:"justify,omitempty"`
	CurTerm     int64              `json:"curTerm,omitempty"`
	CurBlockNum int64              `json:"curBlockNum,omitempty"`
	// TargetBits 作为一个复用字段,记录ChainedBFT发生回滚时,当前的TipHeight,此处用int32代替int64,理论上可能造成错误
	TargetBits int32 `json:"targetBits,omitempty"`
}

历史共识存储字段

func ParseOldQCStorage

func ParseOldQCStorage(storage []byte) (*ConsensusStorage, error)

ParseOldQCStorage 将有Justify结构的老共识结构解析出来

type LedgerCommitInfo

type LedgerCommitInfo struct {
	CommitStateId []byte //表示本地账本状态,TODO: = 本地账本merkel root
	VoteInfoHash  []byte //表示本地vote的vote_info的哈希,即本地QC的最新状态
}

ledgerCommitInfo 表示的是本地账本和QC存储的状态

type ProposalNode

type ProposalNode struct {
	QC   QuorumCert
	Sons []*ProposalNode
}

func NewTreeNode

func NewTreeNode(ledger base.LedgerRely, height int64) *ProposalNode

type QCPendingTree

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

PendingTree 是一个内存的QC状态存储树,仅存放目前未Commit(即可能触发账本回滚)的区块信息 当PendingTree中的某个节点有[严格连续的]三代子孙后,将出发针对该节点的账本Commit操作 本数据结构替代原有Chained-BFT的三层QC存储,即proposalQC,generateQC和lockedQC

func InitQCTree

func InitQCTree(startHeight int64, ledger base.LedgerRely, log logger.Logger) *QCPendingTree

InitQCTree 创建smr需要的QC树存储,该Tree存储了目前待commit的QC信息

func MockTree

func MockTree(genesis *ProposalNode, root *ProposalNode, highQC *ProposalNode,
	genericQC *ProposalNode, lockedQC *ProposalNode, commitQC *ProposalNode,
	log logger.Logger) *QCPendingTree

func (*QCPendingTree) DFSQueryNode

func (t *QCPendingTree) DFSQueryNode(id []byte) *ProposalNode

DFSQueryNode 从root节点开始DFS寻找,TODO:待优化

func (*QCPendingTree) EnforceUpdateHighQC

func (t *QCPendingTree) EnforceUpdateHighQC(inProposalId []byte) error

EnforceUpdateHighQC 强制更改HighQC指针,用于错误时回滚,本实现没有timeoutQC因此需要此方法

func (*QCPendingTree) GetCommitQC

func (t *QCPendingTree) GetCommitQC() *ProposalNode

func (*QCPendingTree) GetGenericQC

func (t *QCPendingTree) GetGenericQC() *ProposalNode

func (*QCPendingTree) GetGenesisQC

func (t *QCPendingTree) GetGenesisQC() *ProposalNode

func (*QCPendingTree) GetHighQC

func (t *QCPendingTree) GetHighQC() *ProposalNode

func (*QCPendingTree) GetLockedQC

func (t *QCPendingTree) GetLockedQC() *ProposalNode

func (*QCPendingTree) GetRootQC

func (t *QCPendingTree) GetRootQC() *ProposalNode

func (*QCPendingTree) MockGetOrphan

func (t *QCPendingTree) MockGetOrphan() *list.List

func (*QCPendingTree) UpdateCommit

func (t *QCPendingTree) UpdateCommit(id []byte)

UpdateCommit 通知ProcessCommit存储落盘,此时的block将不再被回滚

func (*QCPendingTree) UpdateHighQC

func (t *QCPendingTree) UpdateHighQC(inProposalId []byte)

UpdateHighQC 对比QC树,将本地HighQC和输入id比较,高度更高的更新为HighQC,此时连同GenericQC、LockedQC、CommitQC一起修改

func (*QCPendingTree) UpdateQCStatus

func (t *QCPendingTree) UpdateQCStatus(node *ProposalNode) error

UpdateQCStatus 更新本地qcTree, insert新节点, 将新节点parentQC和本地HighQC对比,如有必要进行更新

type QuorumCert

type QuorumCert interface {
	GetProposalView() int64
	GetProposalId() []byte
	GetParentProposalId() []byte
	GetParentView() int64
	GetSignsInfo() []*protos.QuorumCertSign
}

func NewQuorumCert

func NewQuorumCert(v *VoteInfo, l *LedgerCommitInfo, s []*protos.QuorumCertSign) QuorumCert

func OldQCToNew

func OldQCToNew(store []byte) (QuorumCert, error)

OldQCToNew 将老的QC pb结构转化为新的QC结构

type QuorumCertImpl

type QuorumCertImpl struct {
	// 本次qc的vote对象,该对象中嵌入了上次的QCid
	VoteInfo *VoteInfo
	// 当前本地账本的状态
	LedgerCommitInfo *LedgerCommitInfo
	// SignInfos is the signs of the leader gathered from replicas of a specifically certType.
	SignInfos []*protos.QuorumCertSign
}

QuorumCertImpl 是HotStuff的基础结构,它表示了一个节点本地状态以及其余节点对该状态的确认

func (*QuorumCertImpl) GetParentProposalId

func (qc *QuorumCertImpl) GetParentProposalId() []byte

func (*QuorumCertImpl) GetParentView

func (qc *QuorumCertImpl) GetParentView() int64

func (*QuorumCertImpl) GetProposalId

func (qc *QuorumCertImpl) GetProposalId() []byte

func (*QuorumCertImpl) GetProposalView

func (qc *QuorumCertImpl) GetProposalView() int64

func (*QuorumCertImpl) GetSignsInfo

func (qc *QuorumCertImpl) GetSignsInfo() []*protos.QuorumCertSign

type VoteInfo

type VoteInfo struct {
	// 本次vote的对象
	ProposalId   []byte
	ProposalView int64
	// 本地上次vote的对象
	ParentId   []byte
	ParentView int64
}

VoteInfo 包含了本次和上次的vote对象

Jump to

Keyboard shortcuts

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