Documentation ¶
Index ¶
- func NewChain(name string, ctx *snow.Context, cfg *config.Config, gs *genesis.Genesis, ...) *blockChain
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) AncestorBlocks(ancestorHeight uint64) ([]*Block, error)
- func (b *Block) BuildState(vbs BlockState) error
- func (b *Block) BuildTxs(vbs BlockState, txs ...*ld.Transaction) choices.Status
- func (b *Block) Builder() ids.Address
- func (b *Block) Bytes() []byte
- func (b *Block) ChainConfig() *genesis.ChainConfig
- func (b *Block) Context() *Context
- func (b *Block) FeeConfig() *genesis.FeeConfig
- func (b *Block) Free()
- func (b *Block) Gas() *big.Int
- func (b *Block) GasPrice() *big.Int
- func (b *Block) GasRebate20() *big.Int
- func (b *Block) Hash() ids.ID32
- func (b *Block) Height() uint64
- func (b *Block) ID() avaids.ID
- func (b *Block) InitState(parent *Block, db database.Database)
- func (b *Block) LD() *ld.Block
- func (b *Block) MarshalJSON() ([]byte, error)
- func (b *Block) NextGasPrice() uint64
- func (b *Block) Parent() avaids.ID
- func (b *Block) Reject(ctx context.Context) error
- func (b *Block) SetBuilder(builder ids.Address)
- func (b *Block) SetBuilderFee(vbs BlockState) error
- func (b *Block) SetContext(ctx *Context)
- func (b *Block) SetStatus(s choices.Status)
- func (b *Block) State() BlockState
- func (b *Block) Status() choices.Status
- func (b *Block) Timestamp() time.Time
- func (b *Block) Timestamp2() uint64
- func (b *Block) TryBuildTxs(txs ...*ld.Transaction) error
- func (b *Block) Unmarshal(data []byte) error
- func (b *Block) Verify(ctx context.Context) error
- type BlockBuilder
- type BlockChain
- type BlockState
- type Context
- type TxPool
- func (p *TxPool) AcceptByBlock(ctx context.Context, blk *ld.Block) error
- func (p *TxPool) FetchToBuild(ctx context.Context, height uint64) (ld.Txs, error)
- func (p *TxPool) LoadByIDs(ctx context.Context, height uint64, txIDs ids.IDList[ids.ID32]) (ld.Txs, error)
- func (p *TxPool) SetCache(height uint64, txs ld.Txs)
- func (p *TxPool) SizeToBuild(ctx context.Context, height uint64) int
- func (p *TxPool) UpdateBuildStatus(ctx context.Context, height uint64, tbs *txpool.TxsBuildStatus)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block is a possible decision that dictates the next canonical block.
Blocks are guaranteed to be Verified, Accepted, and Rejected in topological order. Specifically, if Verify is called, then the parent has already been verified. If Accept is called, then the parent has already been accepted. If Reject is called, the parent has already been accepted or rejected.
If the status of the block is Unknown, ID is assumed to be able to be called. If the status of the block is Accepted or Rejected; Parent, Verify, Accept, and Reject will never be called.
func (*Block) Accept ¶
Accept implements the snowman.Block choices.Decidable Accept interface This element will be accepted by every correct node in the network. Accept sets this block's status to Accepted and sets lastAccepted to this block's ID and saves this info to stateDB.
func (*Block) AncestorBlocks ¶
AncestorBlocks returns this block's ancestors, from ancestorHeight to block' height, not including this block. The ancestorHeight must >= LastAcceptedBlock's height.
func (*Block) BuildState ¶
func (b *Block) BuildState(vbs BlockState) error
func (*Block) BuildTxs ¶
func (b *Block) BuildTxs(vbs BlockState, txs ...*ld.Transaction) choices.Status
func (*Block) Bytes ¶
Bytes implements the snowman.Block Bytes interface Bytes returns the binary representation of this block. This is used for sending blocks to peers. The bytes should be able to be parsed into the same block on another node.
func (*Block) ChainConfig ¶
func (b *Block) ChainConfig() *genesis.ChainConfig
func (*Block) GasRebate20 ¶
Regard to pareto 80/20 Rule 20% to block builder, 80% to block shares, GasRebate20 = Gas * GasPrice * (GasRebateRate / 100) * 20%
func (*Block) Height ¶
Height implements the snowman.Block Height interface Height returns this block's height. The genesis block has height 0.
func (*Block) ID ¶
ID implements the snowman.Block choices.Decidable ID interface ID returns a unique ID for this element.
func (*Block) MarshalJSON ¶
func (*Block) NextGasPrice ¶
NextGasPrice returns the next block's gas price. It should be called after the block is verified.
func (*Block) Parent ¶
Parent implements the snowman.Block Parent interface Parent returns the ID of this block's parent.
func (*Block) Reject ¶
Reject implements the snowman.Block choices.Decidable Reject interface This element will not be accepted by any correct node in the network.
func (*Block) SetBuilder ¶
func (*Block) SetBuilderFee ¶
func (b *Block) SetBuilderFee(vbs BlockState) error
func (*Block) SetContext ¶
func (*Block) State ¶
func (b *Block) State() BlockState
func (*Block) Status ¶
Status implements the snowman.Block choices.Decidable Status interface Status returns this element's current status. If Accept has been called on an element with this ID, Accepted should be returned. Similarly, if Reject has been called on an element with this ID, Rejected should be returned. If the contents of this element are unknown, then Unknown should be returned. Otherwise, Processing should be returned.
func (*Block) Timestamp ¶
Timestamp implements the snowman.Block Timestamp interface Timestamp returns this block's time. The genesis block has timestamp 0.
func (*Block) Timestamp2 ¶
func (*Block) TryBuildTxs ¶
func (b *Block) TryBuildTxs(txs ...*ld.Transaction) error
type BlockBuilder ¶
type BlockBuilder struct {
// contains filtered or unexported fields
}
func NewBlockBuilder ¶
func NewBlockBuilder(txPool *TxPool, toEngine chan<- common.Message) *BlockBuilder
func (*BlockBuilder) HandlePreferenceBlock ¶
func (b *BlockBuilder) HandlePreferenceBlock(ctx context.Context, height uint64)
HandlePreferenceBlock should be called immediately after [VM.SetPreference].
func (*BlockBuilder) SignalTxsReady ¶
func (b *BlockBuilder) SignalTxsReady()
SignalTxsReady should be called immediately when a new tx incoming
type BlockChain ¶
type BlockChain interface { // global context Context() *Context Info() map[string]any DB() database.Database // global state HealthCheck(context.Context) (any, error) Bootstrap(context.Context) error State() snow.State SetState(context.Context, snow.State) error TotalSupply(context.Context) *big.Int // blocks state IsBuilder() bool BuildBlock(context.Context) (*Block, error) ParseBlock(context.Context, []byte) (*Block, error) GetBlockIDAtHeight(context.Context, uint64) (ids.ID32, error) GetBlockAtHeight(context.Context, uint64) (*Block, error) GetBlock(context.Context, ids.ID32) (*Block, error) LastAcceptedBlock(context.Context) *Block SetLastAccepted(context.Context, *Block) error PreferredBlock() *Block SetPreference(context.Context, ids.ID32) error AddVerifiedBlock(*Block) GetVerifiedBlock(ids.ID32) *Block // txs GetGenesisTxs() ld.Txs PreVerifyPOSTxs(context.Context, ...*ld.Transaction) error LoadTxsByIDsFromPOS(context.Context, uint64, []ids.ID32) (ld.Txs, error) LoadAccount(context.Context, ids.Address) (*ld.Account, error) LoadModel(context.Context, ids.ModelID) (*ld.ModelInfo, error) LoadData(context.Context, ids.DataID) (*ld.DataInfo, error) LoadPrevData(context.Context, ids.DataID, uint64) (*ld.DataInfo, error) LoadRawData(context.Context, string, []byte) ([]byte, error) }
BlockChain defines methods to manage state with Blocks and LastAcceptedIDs.
type BlockState ¶
type Context ¶
func NewContext ¶
func (*Context) BuilderSigner ¶ added in v0.1.1
func (*Context) Chain ¶
func (c *Context) Chain() BlockChain
func (*Context) ChainConfig ¶
func (c *Context) ChainConfig() *genesis.ChainConfig
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}