state

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockStoreState added in v1.2.1

type BlockStoreState struct {
	Height          uint64
	Hash            *bc.Hash
	FinalizedHeight uint64
	FinalizedHash   *bc.Hash
}

BlockStoreState represents the core's db status

type Checkpoint added in v1.2.1

type Checkpoint struct {
	Height     uint64
	Hash       bc.Hash
	ParentHash bc.Hash
	Timestamp  uint64
	Status     CheckpointStatus

	Rewards map[string]uint64 // controlProgram -> num of reward
	Votes   map[string]uint64 // pubKey -> num of vote

	// only save in the memory, not be persisted
	Parent   *Checkpoint      `json:"-"`
	SupLinks []*types.SupLink `json:"-"`
}

Checkpoint represent the block/hash under consideration for finality for a given epoch. This block is the last block of the previous epoch. Rather than dealing with every block, Casper only considers checkpoints for finalization. When a checkpoint is explicitly finalized, all ancestor blocks of the checkpoint are implicitly finalized.

func NewCheckpoint added in v1.2.1

func NewCheckpoint(parent *Checkpoint) *Checkpoint

NewCheckpoint create a new checkpoint instance

func (*Checkpoint) AddVerification added in v1.2.1

func (c *Checkpoint) AddVerification(sourceHash bc.Hash, sourceHeight uint64, validatorOrder int, signature []byte) *types.SupLink

AddVerification add a valid verification to checkpoint's supLink

func (*Checkpoint) AllValidators added in v1.2.1

func (c *Checkpoint) AllValidators() []*Validator

AllValidators return all validators has vote num

func (*Checkpoint) ContainsVerification added in v1.2.1

func (c *Checkpoint) ContainsVerification(validatorOrder int, sourceHash *bc.Hash) bool

ContainsVerification return whether the specified validator has add verification to current checkpoint sourceHash not as filter if is nil,

func (*Checkpoint) EffectiveValidators added in v1.2.1

func (c *Checkpoint) EffectiveValidators() map[string]*Validator

EffectiveValidators return next epoch of effective validators, if the status of checkpoint is growing, return empty

func (*Checkpoint) GetValidator added in v1.2.1

func (c *Checkpoint) GetValidator(timeStamp uint64) *Validator

func (*Checkpoint) Increase added in v1.2.1

func (c *Checkpoint) Increase(block *types.Block) error

Increase will increase the height of checkpoint

type CheckpointStatus added in v1.2.1

type CheckpointStatus uint8

CheckpointStatus represent current status of checkpoint

const (
	// Growing means that the checkpoint has not ended the current epoch
	Growing CheckpointStatus = iota

	// Unjustified means thant the checkpoint has ended the current epoch, but not been justified
	Unjustified

	// Justified if checkpoint is the root, or there exists a super link c′ → c where c′ is justified
	Justified

	// Finalized if checkpoint c is justified and there is a sup link c→c′ where c′is a direct child of c
	Finalized
)

type ContractViewpoint added in v1.2.1

type ContractViewpoint struct {
	AttachEntries map[[32]byte][]byte
	DetachEntries map[[32]byte][]byte
}

ContractViewpoint represents a view into the set of registered contract

func NewContractViewpoint added in v1.2.1

func NewContractViewpoint() *ContractViewpoint

NewContractViewpoint returns a new empty contract view.

func (*ContractViewpoint) ApplyBlock added in v1.2.1

func (view *ContractViewpoint) ApplyBlock(block *types.Block) error

ApplyBlock apply block contract to contract view

func (*ContractViewpoint) DetachBlock added in v1.2.1

func (view *ContractViewpoint) DetachBlock(block *types.Block) error

DetachBlock detach block contract to contract view

type Store added in v1.2.1

type Store interface {
	BlockExist(*bc.Hash) bool

	GetBlock(*bc.Hash) (*types.Block, error)
	GetBlockHeader(*bc.Hash) (*types.BlockHeader, error)
	GetStoreStatus() *BlockStoreState
	GetTransactionsUtxo(*UtxoViewpoint, []*bc.Tx) error
	GetUtxo(*bc.Hash) (*storage.UtxoEntry, error)
	GetMainChainHash(uint64) (*bc.Hash, error)
	GetContract(hash [32]byte) ([]byte, error)

	GetCheckpoint(*bc.Hash) (*Checkpoint, error)
	CheckpointsFromNode(height uint64, hash *bc.Hash) ([]*Checkpoint, error)
	GetCheckpointsByHeight(uint64) ([]*Checkpoint, error)
	SaveCheckpoints([]*Checkpoint) error

	SaveBlock(*types.Block) error
	SaveBlockHeader(*types.BlockHeader) error
	SaveChainStatus(*types.BlockHeader, []*types.BlockHeader, *UtxoViewpoint, *ContractViewpoint, uint64, *bc.Hash) error
}

Store provides storage interface for blockchain data

type UtxoViewpoint added in v0.3.0

type UtxoViewpoint struct {
	Entries map[bc.Hash]*storage.UtxoEntry
}

UtxoViewpoint represents a view into the set of unspent transaction outputs

func NewUtxoViewpoint added in v0.3.0

func NewUtxoViewpoint() *UtxoViewpoint

NewUtxoViewpoint returns a new empty unspent transaction output view.

func (*UtxoViewpoint) ApplyBlock added in v0.3.0

func (view *UtxoViewpoint) ApplyBlock(block *bc.Block) error

func (*UtxoViewpoint) ApplyTransaction added in v0.3.0

func (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx) error

func (*UtxoViewpoint) CanSpend added in v1.0.5

func (view *UtxoViewpoint) CanSpend(hash *bc.Hash) bool

func (*UtxoViewpoint) DetachBlock added in v0.3.0

func (view *UtxoViewpoint) DetachBlock(block *bc.Block) error

func (*UtxoViewpoint) DetachTransaction added in v0.3.0

func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx) error

func (*UtxoViewpoint) HasUtxo added in v0.3.0

func (view *UtxoViewpoint) HasUtxo(hash *bc.Hash) bool

type Validator added in v1.2.1

type Validator struct {
	PubKey  string
	Order   int
	VoteNum uint64
}

Validator represent the participants of the PoS network Responsible for block generation and verification

Jump to

Keyboard shortcuts

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