Documentation
¶
Index ¶
- type BlockStoreState
- type Checkpoint
- func (c *Checkpoint) AddVerification(sourceHash bc.Hash, sourceHeight uint64, validatorOrder int, signature []byte) *types.SupLink
- func (c *Checkpoint) AllValidators() []*Validator
- func (c *Checkpoint) ContainsVerification(validatorOrder int, sourceHash *bc.Hash) bool
- func (c *Checkpoint) EffectiveValidators() map[string]*Validator
- func (c *Checkpoint) GetValidator(timeStamp uint64) *Validator
- func (c *Checkpoint) Increase(block *types.Block) error
- type CheckpointStatus
- type ContractViewpoint
- type Store
- type UtxoViewpoint
- func (view *UtxoViewpoint) ApplyBlock(block *bc.Block) error
- func (view *UtxoViewpoint) ApplyTransaction(block *bc.Block, tx *bc.Tx) error
- func (view *UtxoViewpoint) CanSpend(hash *bc.Hash) bool
- func (view *UtxoViewpoint) DetachBlock(block *bc.Block) error
- func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx) error
- func (view *UtxoViewpoint) HasUtxo(hash *bc.Hash) bool
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockStoreState ¶
type BlockStoreState struct {
Height uint64
Hash *bc.Hash
FinalizedHeight uint64
FinalizedHash *bc.Hash
}
BlockStoreState represents the core's db status
type Checkpoint ¶
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 ¶
func NewCheckpoint(parent *Checkpoint) *Checkpoint
NewCheckpoint create a new checkpoint instance
func (*Checkpoint) AddVerification ¶
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 ¶
func (c *Checkpoint) AllValidators() []*Validator
AllValidators return all validators has vote num
func (*Checkpoint) ContainsVerification ¶
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 ¶
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 ¶
func (c *Checkpoint) GetValidator(timeStamp uint64) *Validator
type CheckpointStatus ¶
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 ¶
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 ¶
func NewContractViewpoint() *ContractViewpoint
NewContractViewpoint returns a new empty contract view.
func (*ContractViewpoint) ApplyBlock ¶
func (view *ContractViewpoint) ApplyBlock(block *types.Block) error
ApplyBlock apply block contract to contract view
func (*ContractViewpoint) DetachBlock ¶
func (view *ContractViewpoint) DetachBlock(block *types.Block) error
DetachBlock detach block contract to contract view
type Store ¶
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 ¶
UtxoViewpoint represents a view into the set of unspent transaction outputs
func NewUtxoViewpoint ¶
func NewUtxoViewpoint() *UtxoViewpoint
NewUtxoViewpoint returns a new empty unspent transaction output view.
func (*UtxoViewpoint) ApplyBlock ¶
func (view *UtxoViewpoint) ApplyBlock(block *bc.Block) error
func (*UtxoViewpoint) ApplyTransaction ¶
func (*UtxoViewpoint) DetachBlock ¶
func (view *UtxoViewpoint) DetachBlock(block *bc.Block) error
func (*UtxoViewpoint) DetachTransaction ¶
func (view *UtxoViewpoint) DetachTransaction(tx *bc.Tx) error