Documentation ¶
Index ¶
- type Casper
- func (c *Casper) ApplyBlock(block *types.Block) (bc.Hash, error)
- func (c *Casper) AuthVerification(msg *ValidCasperSignMsg) error
- func (c *Casper) BestChain() bc.Hash
- func (c *Casper) LastFinalized() (uint64, bc.Hash)
- func (c *Casper) LastJustified() (uint64, bc.Hash)
- func (c *Casper) ParentCheckpoint(blockHash *bc.Hash) (*state.Checkpoint, error)
- func (c *Casper) ParentCheckpointByPrevHash(prevBlockHash *bc.Hash) (*state.Checkpoint, error)
- func (c *Casper) RollbackCh() <-chan *RollbackMsg
- type RollbackMsg
- type ValidCasperSignMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Casper ¶
type Casper struct {
// contains filtered or unexported fields
}
Casper is BFT based proof of stack consensus algorithm, it provides safety and liveness in theory, it's design mainly refers to https://github.com/ethereum/research/blob/master/papers/casper-basics/casper_basics.pdf
func NewCasper ¶
func NewCasper(store state.Store, queue msgQueue, checkpoints []*state.Checkpoint) *Casper
NewCasper create a new instance of Casper argument checkpoints load the checkpoints from leveldb the first element of checkpoints must genesis checkpoint or the last finalized checkpoint in order to reduce memory space the others must be successors of first one
func (*Casper) ApplyBlock ¶
ApplyBlock used to receive a new block from upper layer, it provides idempotence and parse the vote and mortgage from the transactions, then save to the checkpoint the tree of checkpoint will grow with the arrival of new blocks it will return verification when an epoch is reached and the current node is the validator, otherwise return nil the chain module must broadcast the verification
func (*Casper) AuthVerification ¶
func (c *Casper) AuthVerification(msg *ValidCasperSignMsg) error
AuthVerification verify whether the Verification is legal. the status of source checkpoint must justified, and an individual validator ν must not publish two distinct Verification ⟨ν,s1,t1,h(s1),h(t1)⟩ and ⟨ν,s2,t2,h(s2),h(t2)⟩, such that either: h(t1) = h(t2) OR h(s1) < h(s2) < h(t2) < h(t1)
func (*Casper) LastFinalized ¶
LastFinalized return the block height and block hash which is finalized at last
func (*Casper) LastJustified ¶
LastJustified return the block height and block hash which is justified at last
func (*Casper) ParentCheckpoint ¶
func (*Casper) ParentCheckpointByPrevHash ¶
func (*Casper) RollbackCh ¶
func (c *Casper) RollbackCh() <-chan *RollbackMsg
type RollbackMsg ¶
RollbackMsg sent the rollback msg to chain core