Documentation ¶
Index ¶
- func GenesisBlockForTesting(db database.IDatabase, addr types.Address, balance *big.Int) *block.Block
- func SetupGenesisBlock(db database.IDatabase, genesis *Genesis) (*params.ChainConfig, types.Hash, error)
- type ExtraStorage
- type Genesis
- type GenesisAccount
- type GenesisAlloc
- type GenesisMismatchError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenesisBlockForTesting ¶
func SetupGenesisBlock ¶
func SetupGenesisBlock(db database.IDatabase, genesis *Genesis) (*params.ChainConfig, types.Hash, error)
SetupGenesisBlock writes or updates the genesis block in db. The block that will be used is:
genesis == nil genesis != nil +------------------------------------------ db has no genesis | main-net default | genesis db has genesis | from DB | genesis (if compatible)
The stored chain configuration will be updated if it is compatible (i.e. does not specify a fork block below the local head block). In case of a conflict, the error is a *params.ConfigCompatError and the new, unwritten config is returned.
The returned chain configuration is never nil.
Types ¶
type ExtraStorage ¶
type Genesis ¶
type Genesis struct { Config *params.ChainConfig `json:"config"` Timestamp uint64 `json:"timestamp"` Alloc GenesisAlloc `json:"alloc"` // These fields are used for consensus tests. Please don't use them // in actual genesis blocks. Number uint64 `json:"number"` ParentHash types.Hash `json:"parentHash"` ConsensusData block.ConsensusData `json:"consensusData"` Extra []ExtraStorage `json:"extra"` }
Genesis specifies the header fields, state of a genesis block. It also defines hard fork switch-over blocks through the chain configuration.
func DefaultGenesisBlock ¶
func DefaultGenesisBlock() *Genesis
DefaultGenesisBlock returns the bchain main net genesis block.
func (*Genesis) Commit ¶
Commit writes the block and state of a genesis specification to the database. The block is committed as the canonical head block.
func (*Genesis) MustCommit ¶
for test MustCommit writes the genesis block and state to db, panicking on error. The block is committed as the canonical head block.
type GenesisAccount ¶
type GenesisAccount struct { Code []byte `json:"code,omitempty"` Storage map[types.Hash]types.Hash `json:"storage,omitempty"` Nonce uint64 `json:"nonce,omitempty"` InterpreterName string `json:"interpreterName,omitempty"` Creator string `json:"creator,omitempty"` }
GenesisAccount is an account in the state of the genesis block.
type GenesisAlloc ¶
type GenesisAlloc map[types.Address]GenesisAccount
type GenesisMismatchError ¶
GenesisMismatchError is raised when trying to overwrite an existing genesis block with an incompatible one.
func (*GenesisMismatchError) Error ¶
func (e *GenesisMismatchError) Error() string