Documentation
¶
Index ¶
- Variables
- type Chain
- func New(db *muxdb.MuxDB, genesis *genesis.Genesis, engine bft.Committer, ...) *Chain
- func NewDefault() (*Chain, error)
- func NewIntegrationTestChain(config genesis.DevConfig, epochLength uint32) (*Chain, error)
- func NewIntegrationTestChainWithGenesis(gene *genesis.Genesis, forkConfig *thor.ForkConfig, epochLength uint32) (*Chain, error)
- func NewWithFork(forkConfig *thor.ForkConfig, epochLength uint32) (*Chain, error)
- func (c *Chain) AddBlock(newBlk *block.Block, stage *state.Stage, receipts tx.Receipts) error
- func (c *Chain) BestBlock() (*block.Block, error)
- func (c *Chain) ChainTag() byte
- func (c *Chain) ClauseCall(account genesis.DevAccount, trx *tx.Transaction, clauseIdx int) ([]byte, uint64, error)
- func (c *Chain) Contract(addr thor.Address, abi *abi.ABI, acc genesis.DevAccount) *Contract
- func (c *Chain) Database() *muxdb.MuxDB
- func (c *Chain) Engine() bft.Committer
- func (c *Chain) Genesis() *genesis.Genesis
- func (c *Chain) GenesisBlock() *block.Block
- func (c *Chain) GetAllBlocks() ([]*block.Block, error)
- func (c *Chain) GetForkConfig() *thor.ForkConfig
- func (c *Chain) GetTxBlock(txID *thor.Bytes32) (*block.Block, error)
- func (c *Chain) GetTxReceipt(txID thor.Bytes32) (*tx.Receipt, error)
- func (c *Chain) LogDB() *logdb.LogDB
- func (c *Chain) MintBlock(account genesis.DevAccount, transactions ...*tx.Transaction) error
- func (c *Chain) MintClauses(account genesis.DevAccount, clauses []*tx.Clause) error
- func (c *Chain) MintTransactions(account genesis.DevAccount, transactions ...*tx.Transaction) error
- func (c *Chain) Repo() *chain.Repository
- func (c *Chain) Stater() *state.Stater
- type Contract
- func (c *Contract) Attach(acc genesis.DevAccount) *Contract
- func (c *Contract) BuildClause(method string, args ...any) (*tx.Clause, error)
- func (c *Contract) BuildTransaction(method string, vet *big.Int, args ...any) (*tx.Transaction, error)
- func (c *Contract) Call(method string, args ...any) ([]byte, error)
- func (c *Contract) CallInto(method string, result any, args ...any) error
- func (c *Contract) MintTransaction(method string, vet *big.Int, args ...any) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents the blockchain structure. It includes database (db), genesis information (genesis), consensus engine (engine), repository for blocks and state (repo), state manager (stater), and the genesis block (genesisBlock).
func NewDefault ¶ added in v2.3.0
NewDefault is a wrapper function that creates a Chain for testing with the default fork config.
func NewIntegrationTestChain ¶
NewIntegrationTestChain is a convenience function that creates a Chain for testing. It uses an in-memory database, development network genesis, and a solo BFT engine.
func NewIntegrationTestChainWithGenesis ¶ added in v2.4.0
func NewWithFork ¶ added in v2.3.0
func NewWithFork(forkConfig *thor.ForkConfig, epochLength uint32) (*Chain, error)
NewWithFork is a wrapper function that creates a Chain for testing with custom forkConfig.
func (*Chain) ClauseCall ¶ added in v2.4.0
func (c *Chain) ClauseCall(account genesis.DevAccount, trx *tx.Transaction, clauseIdx int) ([]byte, uint64, error)
ClauseCall executes contract call with clause referenced by the clauseIdx parameter, the rest of tx is passed as is.
func (*Chain) Contract ¶ added in v2.4.0
Contract creates a new contract instance with the provided address and ABI.
func (*Chain) Engine ¶
Engine returns the consensus engine responsible for the blockchain's consensus mechanism.
func (*Chain) Genesis ¶ added in v2.4.0
Genesis returns the genesis information of the chain, which includes the initial state and configuration.
func (*Chain) GenesisBlock ¶
GenesisBlock returns the genesis block of the chain, which is the first block in the blockchain.
func (*Chain) GetAllBlocks ¶
GetAllBlocks retrieves all blocks from the blockchain, starting from the best block and moving backward to the genesis block. It limits the retrieval time to 5 seconds to avoid excessive delays.
func (*Chain) GetForkConfig ¶
func (c *Chain) GetForkConfig() *thor.ForkConfig
GetForkConfig returns the current fork configuration based on the ID of the genesis block.
func (*Chain) GetTxBlock ¶ added in v2.4.0
func (*Chain) GetTxReceipt ¶ added in v2.4.0
func (*Chain) MintBlock ¶
func (c *Chain) MintBlock(account genesis.DevAccount, transactions ...*tx.Transaction) error
MintBlock creates and finalizes a new block with the given transactions. It schedules a new block, adopts transactions, packs them into a block, and commits it to the chain.
func (*Chain) MintClauses ¶ added in v2.2.0
MintClauses creates a transaction with the provided clauses and adds it to the blockchain.
func (*Chain) MintTransactions ¶
func (c *Chain) MintTransactions(account genesis.DevAccount, transactions ...*tx.Transaction) error
MintTransactions creates a block with the provided transactions and adds it to the blockchain. It wraps the transactions with receipts and passes them to MintTransactionsWithReceiptFunc.
func (*Chain) Repo ¶
func (c *Chain) Repo() *chain.Repository
Repo returns the blockchain's repository, which stores blocks and other data.
type Contract ¶ added in v2.4.0
type Contract struct {
// contains filtered or unexported fields
}
func NewContract ¶ added in v2.4.0
func (*Contract) Attach ¶ added in v2.4.0
func (c *Contract) Attach(acc genesis.DevAccount) *Contract