genesis

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenesisBlockForTesting

func GenesisBlockForTesting(db database.IDatabase, addr types.Address, balance *big.Int) *block.Block

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 ExtraStorage struct {
	Key []byte `json:"key"`
	Val []byte `json:"val"`
}

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

func (g *Genesis) Commit(db database.IDatabase) (*block.Block, error)

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

func (g *Genesis) MustCommit(db database.IDatabase) *block.Block

for test MustCommit writes the genesis block and state to db, panicking on error. The block is committed as the canonical head block.

func (*Genesis) ToBlock

func (g *Genesis) ToBlock() (*block.Block, *state.StateDB)

ToBlock creates the block and state of a genesis specification.

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

type GenesisMismatchError struct {
	Stored types.Hash
	New    types.Hash
}

GenesisMismatchError is raised when trying to overwrite an existing genesis block with an incompatible one.

func (*GenesisMismatchError) Error

func (e *GenesisMismatchError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL