storage

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

This section is empty.

Types

type LedgerCommitInfo

type LedgerCommitInfo struct {
	CommitStateId []byte
	VoteInfoHash  []byte
}

ledgerCommitInfo 表示的是本地账本和QC存储的状态,包含一个commitStateId和一个voteInfoHash commitStateId 表示本地账本状态,TODO: = 本地账本merkel root voteInfoHash 表示本地vote的vote_info的哈希,即本地QC的最新状态

type ProposalNode

type ProposalNode struct {
	In QuorumCertInterface
	// Parent QuorumCertInterface
	Sons []*ProposalNode
}

func NewTreeNode

func NewTreeNode(ledger cctx.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 cctx.LedgerRely, log logs.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 logs.Logger) *QCPendingTree

func (*QCPendingTree) DFSQueryNode

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

DFSQueryNode实现的比较简单,从root节点开始寻找,后续有更优方法可优化

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将不再被回滚 同时此方法将原先的root更改为commit node,因为commit node在本BFT中已确定不会回滚

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

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

type QuorumCert

type QuorumCert struct {
	// 本次qc的vote对象,该对象中嵌入了上次的QCid,因此删除原有的ProposalMsg部分
	VoteInfo *VoteInfo
	// 当前本地账本的状态
	LedgerCommitInfo *LedgerCommitInfo
	// SignInfos is the signs of the leader gathered from replicas of a specifically certType.
	SignInfos []*pb.QuorumCertSign
}

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

func (*QuorumCert) GetParentProposalId

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

func (*QuorumCert) GetParentView

func (qc *QuorumCert) GetParentView() int64

func (*QuorumCert) GetProposalId

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

func (*QuorumCert) GetProposalView

func (qc *QuorumCert) GetProposalView() int64

func (*QuorumCert) GetSignsInfo

func (qc *QuorumCert) GetSignsInfo() []*pb.QuorumCertSign

type QuorumCertInterface

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

QuorumCertInterface 接口

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