chain

package
v0.0.0-...-8f649d9 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GenesisGasLimit is the default gas limit of the Genesis block.
	GenesisGasLimit uint64 = 4712388
	// GenesisDifficulty is the default difficulty of the Genesis block.
	GenesisDifficulty = big.NewInt(131072)
)

Functions

func ResolveNetworkID

func ResolveNetworkID(id uint) string

ResolveNetworkID returns the name of the network or the string of the id if it is not found

Types

type Bootnodes

type Bootnodes []string

type Chain

type Chain struct {
	Name      string    `json:"name"`
	Genesis   *Genesis  `json:"genesis"`
	Params    *Params   `json:"params"`
	Bootnodes Bootnodes `json:"bootnodes"`
}

func ImportFromFile

func ImportFromFile(filename string) (*Chain, error)

ImportFromFile imports a chain from a filepath

func ImportFromName

func ImportFromName(chain string) (*Chain, error)

ImportFromName imports a chain from the precompiled json chains (i.e. foundation)

type Fork

type Fork uint64

func NewFork

func NewFork(n uint64) *Fork

func (Fork) Active

func (f Fork) Active(block uint64) bool

func (Fork) Int

func (f Fork) Int() *big.Int

type Forks

type Forks struct {
	Homestead      *Fork `json:"homestead,omitempty"`
	Byzantium      *Fork `json:"byzantium,omitempty"`
	Constantinople *Fork `json:"constantinople,omitempty"`
	Petersburg     *Fork `json:"petersburg,omitempty"`
	EIP150         *Fork `json:"EIP150,omitempty"`
	EIP158         *Fork `json:"EIP158,omitempty"`
	EIP155         *Fork `json:"EIP155,omitempty"`
}

Forks specifies when each fork is activated

func (*Forks) At

func (f *Forks) At(block uint64) ForksInTime

func (*Forks) IsByzantium

func (f *Forks) IsByzantium(block uint64) bool

func (*Forks) IsConstantinople

func (f *Forks) IsConstantinople(block uint64) bool

func (*Forks) IsEIP150

func (f *Forks) IsEIP150(block uint64) bool

func (*Forks) IsEIP155

func (f *Forks) IsEIP155(block uint64) bool

func (*Forks) IsEIP158

func (f *Forks) IsEIP158(block uint64) bool

func (*Forks) IsHomestead

func (f *Forks) IsHomestead(block uint64) bool

func (*Forks) IsPetersburg

func (f *Forks) IsPetersburg(block uint64) bool

type ForksInTime

type ForksInTime struct {
	Homestead, Byzantium, Constantinople, Petersburg, EIP150, EIP158, EIP155 bool
}

type Genesis

type Genesis struct {
	Config *Params `json:"config"`

	Nonce      [8]byte       `json:"nonce"`
	Timestamp  uint64        `json:"timestamp"`
	ExtraData  []byte        `json:"extraData,omitempty"`
	GasLimit   uint64        `json:"gasLimit"`
	Difficulty uint64        `json:"difficulty"`
	Mixhash    types.Hash    `json:"mixHash"`
	Coinbase   types.Address `json:"coinbase"`
	Alloc      GenesisAlloc  `json:"alloc,omitempty"`

	// Only for testing
	Number     uint64     `json:"number"`
	GasUsed    uint64     `json:"gasUsed"`
	ParentHash types.Hash `json:"parentHash"`
}

Genesis specifies the header fields, state of a genesis block

func (*Genesis) MarshalJSON

func (g *Genesis) MarshalJSON() ([]byte, error)

MarshalJSON implements the json interface

func (*Genesis) ToBlock

func (g *Genesis) ToBlock() *types.Header

func (*Genesis) UnmarshalJSON

func (g *Genesis) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json interface

type GenesisAccount

type GenesisAccount struct {
	Code       []byte                    `json:"code,omitempty"`
	Storage    map[types.Hash]types.Hash `json:"storage,omitempty"`
	Balance    *big.Int                  `json:"balance,omitempty"`
	Nonce      uint64                    `json:"nonce,omitempty"`
	PrivateKey []byte                    `json:"secretKey,omitempty"` // for tests
}

GenesisAccount is an account in the state of the genesis block.

func (*GenesisAccount) UnmarshalJSON

func (g *GenesisAccount) UnmarshalJSON(data []byte) error

type GenesisAlloc

type GenesisAlloc map[types.Address]GenesisAccount

GenesisAlloc specifies the initial state that is part of the genesis block.

type Params

type Params struct {
	Forks   *Forks                 `json:"forks"`
	ChainID int                    `json:"chainID"`
	Engine  map[string]interface{} `json:"engine"`
}

Params are all the set of params for the chain

func (*Params) GetEngine

func (p *Params) GetEngine() string

Jump to

Keyboard shortcuts

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