cache

package
v0.0.0-...-bda353b Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLedgerCache

func NewLedgerCache(chainId string) protocol.LedgerCache

NewLedgerCache get a ledger cache. One ledger cache for one chain.

func NewProposalCache

func NewProposalCache(
	chainConf protocol.ChainConf,
	ledgerCache protocol.LedgerCache,
	logger protocol.Logger) protocol.ProposalCache

NewProposalCache get a ProposalCache. One ProposalCache for one chain.

Types

type LedgerCache

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

LedgerCache is used for cache current block info

func (*LedgerCache) CurrentHeight

func (lc *LedgerCache) CurrentHeight() (uint64, error)

CurrentHeight get current block height

func (*LedgerCache) GetLastCommittedBlock

func (lc *LedgerCache) GetLastCommittedBlock() *commonpb.Block

GetLastCommittedBlock get the latest committed block

func (*LedgerCache) SetLastCommittedBlock

func (lc *LedgerCache) SetLastCommittedBlock(b *commonpb.Block)

SetLastCommittedBlock set the latest committed block

type ProposalCache

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

ProposalCache is used for cache proposal blocks

func (*ProposalCache) ClearProposedBlockAt

func (pc *ProposalCache) ClearProposedBlockAt(height uint64)

ClearProposedBlockAt clear proposed blocks with height.

func (*ProposalCache) ClearTheBlock

func (pc *ProposalCache) ClearTheBlock(block *commonpb.Block)

func (*ProposalCache) DiscardBlocks

func (pc *ProposalCache) DiscardBlocks(baseHeight uint64) []*commonpb.Block

func (*ProposalCache) GetProposedBlock

func (pc *ProposalCache) GetProposedBlock(b *commonpb.Block) (
	*commonpb.Block, map[string]*commonpb.TxRWSet, map[string][]*commonpb.ContractEvent)

GetProposedBlock get proposed block with specific block hash in current consensus height.

func (*ProposalCache) GetProposedBlockByHashAndHeight

func (pc *ProposalCache) GetProposedBlockByHashAndHeight(hash []byte, height uint64) (
	*commonpb.Block, map[string]*commonpb.TxRWSet)

GetProposedBlockByHashAndHeight get proposed block by block hash and block height.

func (*ProposalCache) GetProposedBlocksAt

func (pc *ProposalCache) GetProposedBlocksAt(height uint64) []*commonpb.Block

GetProposedBlocksAt get all proposed blocks at a specific height. It is possible that generate several proposal blocks in one height because of some unpredictable situation of consensus.

func (*ProposalCache) GetSelfProposedBlockAt

func (pc *ProposalCache) GetSelfProposedBlockAt(height uint64) *commonpb.Block

GetSelfProposedBlockAt get proposed block that is proposed by node itself.

func (*ProposalCache) HasProposedBlockAt

func (pc *ProposalCache) HasProposedBlockAt(height uint64) bool

HasProposedBlockAt return if a proposed block has cached in current consensus height.

func (*ProposalCache) IsProposedAt

func (pc *ProposalCache) IsProposedAt(height uint64) bool

IsProposedAt return if this node has proposed a block as proposer.

func (*ProposalCache) KeepProposedBlock

func (pc *ProposalCache) KeepProposedBlock(hash []byte, height uint64) []*commonpb.Block

Remove proposed block in height except the specific block.

func (*ProposalCache) ResetProposedAt

func (pc *ProposalCache) ResetProposedAt(height uint64)

ResetProposedAt reset propose status of this node.

func (*ProposalCache) SetProposedAt

func (pc *ProposalCache) SetProposedAt(height uint64)

SetProposedAt to mark this node has proposed a block as proposer.

func (*ProposalCache) SetProposedBlock

func (pc *ProposalCache) SetProposedBlock(b *commonpb.Block, rwSetMap map[string]*commonpb.TxRWSet,
	contractEventMap map[string][]*commonpb.ContractEvent, selfPropose bool) error

SetProposedBlock set porposed block in current consensus height, after it's generated or verified.

Jump to

Keyboard shortcuts

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