Documentation
¶
Index ¶
- Variables
- type Blockchain
- type BlockchainNotifee
- type Chain
- func (c *Chain) Genesis() *chainindex.BlockRow
- func (c *Chain) GetNodeByHeight(height uint64) (*chainindex.BlockRow, bool)
- func (c *Chain) GetNodeBySlot(slot uint64) (*chainindex.BlockRow, bool)
- func (c *Chain) Height() uint64
- func (c *Chain) Next(row *chainindex.BlockRow) (*chainindex.BlockRow, bool)
- func (c *Chain) SetTip(row *chainindex.BlockRow)
- func (c *Chain) Tip() *chainindex.BlockRow
- type StateService
- type View
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTooFarInFuture = fmt.Errorf("tried to get block too far in future")
Functions ¶
This section is empty.
Types ¶
type Blockchain ¶
type Blockchain interface { Start() (err error) Stop() State() StateService GenesisTime() time.Time GetBlock(h chainhash.Hash) (block *primitives.Block, err error) GetRawBlock(h chainhash.Hash) (block []byte, err error) Notify(n BlockchainNotifee) Unnotify(n BlockchainNotifee) UpdateChainHead(possible chainhash.Hash) error ProcessBlock(block *primitives.Block) error }
Blockchain is an interface for blockchain
func NewBlockchain ¶
func NewBlockchain(db blockdb.Database) (Blockchain, error)
NewBlockchain constructs a new blockchain.
type BlockchainNotifee ¶
type BlockchainNotifee interface { // NewTip notifies of a new tip added to the blockchain. Do not mutate state. NewTip(*chainindex.BlockRow, *primitives.Block, state.State, []*primitives.EpochReceipt) ProposerSlashingConditionViolated(slashing *primitives.ProposerSlashing) }
BlockchainNotifee is a type that is notified when something changes with the blockchain.
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func NewChain ¶
func NewChain(genesisBlock *chainindex.BlockRow) *Chain
NewBlockchain creates a new chain.
func (*Chain) Genesis ¶
func (c *Chain) Genesis() *chainindex.BlockRow
func (*Chain) GetNodeByHeight ¶
func (c *Chain) GetNodeByHeight(height uint64) (*chainindex.BlockRow, bool)
func (*Chain) GetNodeBySlot ¶
func (c *Chain) GetNodeBySlot(slot uint64) (*chainindex.BlockRow, bool)
GetNodeBySlot returns the node at a specific slot.
func (*Chain) Next ¶
func (c *Chain) Next(row *chainindex.BlockRow) (*chainindex.BlockRow, bool)
func (*Chain) SetTip ¶
func (c *Chain) SetTip(row *chainindex.BlockRow)
SetTip sets the tip of the chain.
func (*Chain) Tip ¶
func (c *Chain) Tip() *chainindex.BlockRow
type StateService ¶
type StateService interface { GetLatestVote(val uint64) (*primitives.MultiValidatorVote, bool) SetLatestVotesIfNeeded(vals []uint64, vote *primitives.MultiValidatorVote) Chain() *Chain Index() *chainindex.BlockIndex SetFinalizedHead(finalizedHash chainhash.Hash, finalizedState state.State) error GetFinalizedHead() (*chainindex.BlockRow, state.State) SetJustifiedHead(justifiedHash chainhash.Hash, justifiedState state.State) error GetJustifiedHead() (*chainindex.BlockRow, state.State) GetStateForHash(hash chainhash.Hash) (state.State, bool) GetStateForHashAtSlot(hash chainhash.Hash, slot uint64, view state.BlockView) (state.State, []*primitives.EpochReceipt, error) Add(block *primitives.Block) (state.State, []*primitives.EpochReceipt, error) RemoveBeforeSlot(slot uint64) GetRowByHash(h chainhash.Hash) (*chainindex.BlockRow, bool) Height() uint64 TipState() state.State TipStateAtSlot(slot uint64) (state.State, error) GetSubView(tip chainhash.Hash) (View, error) Tip() *chainindex.BlockRow }
func NewStateService ¶
func NewStateService(db blockdb.Database) (StateService, error)
NewStateService constructs a new state service.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is a view of a certain chain in the block tree so that block processing can access valid blocks.
func NewChainView ¶
func NewChainView(tip *chainindex.BlockRow) View
NewChainView creates a new chain view with a certain tip
func (*View) GetHashBySlot ¶
GetHashBySlot gets a hash of a block in a certain slot.
func (*View) SetTipSlot ¶
SetTipSlot sets the effective tip slot (which may be updated due to slot transitions)
Click to show internal directories.
Click to hide internal directories.