storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommitFailed = errors.New("commit failed")
)
View Source
var VoteKey = []byte("vote")

Functions

func QcFromGenesisState

func QcFromGenesisState(partitionRecords []*genesis.GenesisPartitionRecord) *drctypes.QuorumCert

func ReadLastTC

func ReadLastTC(db keyvaluedb.KeyValueDB) (*abtypes.TimeoutCert, error)

func ReadVote

func ReadVote(db keyvaluedb.KeyValueDB) (any, error)

func ToRecoveryInputData

func ToRecoveryInputData(data []*InputData) []*abdrc.InputData

ToRecoveryInputData function for type conversion

func WriteLastTC

func WriteLastTC(db keyvaluedb.KeyValueDB, tc *abtypes.TimeoutCert) error

func WriteVote

func WriteVote(db keyvaluedb.KeyValueDB, vote any) error

Types

type BlockStore

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

func New

func NewFromState

func NewFromState(hash gocrypto.Hash, stateMsg *abdrc.StateMsg, db keyvaluedb.KeyValueDB) (*BlockStore, error)

func (*BlockStore) Add

func (x *BlockStore) Add(block *drctypes.BlockData, verifier IRChangeReqVerifier) ([]byte, error)

Add adds new round state to pipeline and returns the new state root hash a.k.a. execStateID

func (*BlockStore) Block

func (x *BlockStore) Block(round uint64) (*ExecutedBlock, error)

Block returns block for given round. When store doesn't have block for the round it returns error.

func (*BlockStore) GetCertificate

func (x *BlockStore) GetCertificate(id types.SystemID) (*types.UnicityCertificate, error)

func (*BlockStore) GetCertificates

func (x *BlockStore) GetCertificates() map[types.SystemID]*types.UnicityCertificate

func (*BlockStore) GetDB

func (x *BlockStore) GetDB() keyvaluedb.KeyValueDB

func (*BlockStore) GetHighQc

func (x *BlockStore) GetHighQc() *drctypes.QuorumCert

func (*BlockStore) GetLastTC

func (x *BlockStore) GetLastTC() (*drctypes.TimeoutCert, error)

func (*BlockStore) GetState

func (x *BlockStore) GetState() *abdrc.StateMsg

func (*BlockStore) IsChangeInProgress

func (x *BlockStore) IsChangeInProgress(sysId types.SystemID) *types.InputRecord

IsChangeInProgress - return input record if sysID has a pending IR change in the pipeline or nil if no change is currently in the pipeline.

func (*BlockStore) ProcessQc

func (*BlockStore) ProcessTc

func (x *BlockStore) ProcessTc(tc *drctypes.TimeoutCert) (rErr error)

func (*BlockStore) ReadLastVote

func (x *BlockStore) ReadLastVote() (any, error)

ReadLastVote returns last sent vote message by this node

func (*BlockStore) StoreLastVote

func (x *BlockStore) StoreLastVote(vote any) error

StoreLastVote stores last sent vote message by this node

type BlockTree

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

func NewBlockTree

func NewBlockTree(bDB keyvaluedb.KeyValueDB) (*BlockTree, error)

func NewBlockTreeFromRecovery

func NewBlockTreeFromRecovery(block *ExecutedBlock, bDB keyvaluedb.KeyValueDB) (*BlockTree, error)

func (*BlockTree) Add

func (bt *BlockTree) Add(block *ExecutedBlock) error

Add adds new leaf to the block tree

func (*BlockTree) Commit

func (bt *BlockTree) Commit(commitQc *abdrc.QuorumCert) (execBlock *ExecutedBlock, err error)

Commit commits block for round and prunes all preceding blocks from the tree, the committed block becomes the new root of the tree

func (*BlockTree) FindBlock

func (bt *BlockTree) FindBlock(round uint64) (*ExecutedBlock, error)

func (*BlockTree) FindPathToRoot

func (bt *BlockTree) FindPathToRoot(round uint64) []*ExecutedBlock

FindPathToRoot finds bath from node with round to root node returns nil in case of failure, when a node is not found otherwise it will return list of data stored in the path nodes, excluding the root data itself, so if the root node is previous node then the list is empty

func (*BlockTree) GetAllUncommittedNodes

func (bt *BlockTree) GetAllUncommittedNodes() []*ExecutedBlock

func (*BlockTree) HighQc

func (bt *BlockTree) HighQc() *abdrc.QuorumCert

func (*BlockTree) InsertQc

func (bt *BlockTree) InsertQc(qc *abdrc.QuorumCert) error

func (*BlockTree) RemoveLeaf

func (bt *BlockTree) RemoveLeaf(round uint64) error

RemoveLeaf removes leaf node if it is not root node

func (*BlockTree) Root

func (bt *BlockTree) Root() *ExecutedBlock

type ExecutedBlock

type ExecutedBlock struct {
	BlockData *drctypes.BlockData  // proposed block
	CurrentIR InputRecords         // all input records in this block
	Changed   SysIDList            // changed partition system identifiers
	HashAlgo  gocrypto.Hash        // hash algorithm for the block
	RootHash  []byte               // resulting root hash
	Qc        *drctypes.QuorumCert // block's quorum certificate (from next view)
	CommitQc  *drctypes.QuorumCert // block's commit certificate
	// contains filtered or unexported fields
}

func NewExecutedBlock

func NewExecutedBlock(hash gocrypto.Hash, newBlock *drctypes.BlockData, parent *ExecutedBlock, verifier IRChangeReqVerifier) (*ExecutedBlock, error)

func NewGenesisBlock

func NewGenesisBlock(hash gocrypto.Hash, pg []*genesis.GenesisPartitionRecord) *ExecutedBlock

func NewRootBlock

func NewRootBlock(hash gocrypto.Hash, block *abdrc.CommittedBlock) (*ExecutedBlock, error)

func (*ExecutedBlock) GenerateCertificates

func (x *ExecutedBlock) GenerateCertificates(commitQc *drctypes.QuorumCert) (map[types.SystemID]*types.UnicityCertificate, error)

func (*ExecutedBlock) GetParentRound

func (x *ExecutedBlock) GetParentRound() uint64

func (*ExecutedBlock) GetRound

func (x *ExecutedBlock) GetRound() uint64

type IRChangeReqVerifier

type IRChangeReqVerifier interface {
	VerifyIRChangeReq(round uint64, irChReq *drctypes.IRChangeReq) (*InputData, error)
}

type InputData

type InputData struct {
	SysID types.SystemID
	IR    *types.InputRecord
	Sdrh  []byte // System Description Record Hash
	// contains filtered or unexported fields
}

type InputRecords

type InputRecords []*InputData

func (InputRecords) Find

func (data InputRecords) Find(sysID types.SystemID) *InputData

func (InputRecords) Update

func (data InputRecords) Update(newInputData *InputData) error

type SysIDList

type SysIDList []types.SystemID

type VoteStore

type VoteStore struct {
	VoteType VoteType
	VoteMsg  cbor.RawMessage
}

type VoteType

type VoteType uint8
const (
	Unknown VoteType = iota
	VoteMsg
	TimeoutVoteMsg
)

Jump to

Keyboard shortcuts

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