genesis

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestFieldsHR = Fields{
	Raw: map[string]map[string]string{},
	Runtime: map[string]map[string]interface{}{
		"system": {
			"code": "mocktestcode",
		},
	},
}

TestFieldsHR instance of human-readable Fields struct for testing, use with TestGenesis

View Source
var TestFieldsRaw = Fields{
	Raw: map[string]map[string]string{
		"top": {"0x3a636f6465": "mocktestcode"},
	},
}

TestFieldsRaw instance of raw Fields struct for testing use with TestGenesis

View Source
var TestGenesis = &Genesis{
	Name:               "gossamer",
	ID:                 "gossamer",
	Bootnodes:          testBootnodes,
	TelemetryEndpoints: append(testEndpoints, testEndpoint1),
	ProtocolID:         testProtocolID,
	Properties:         testProperties,
	ForkBlocks:         testForkBlocks,
	BadBlocks:          testBadBlocks,
}

TestGenesis instance of Genesis struct for testing

Functions

func BuildFromMap added in v0.2.0

func BuildFromMap(m map[string][]byte, gen *Genesis) error

BuildFromMap builds genesis fields data from map

func CreateTestGenesisJSONFile added in v0.2.0

func CreateTestGenesisJSONFile(asRaw bool) (string, error)

CreateTestGenesisJSONFile utility to create mock test genesis JSON file

func NewGenesisBlockFromTrie

func NewGenesisBlockFromTrie(t *trie.Trie) (*types.Header, error)

NewGenesisBlockFromTrie creates a genesis block from the provided trie

func NewTrieFromGenesis

func NewTrieFromGenesis(g *Genesis) (*trie.Trie, error)

NewTrieFromGenesis creates a new trie from the raw genesis data

Types

type Data

type Data struct {
	Name               string
	ID                 string
	ChainType          string
	Bootnodes          [][]byte
	TelemetryEndpoints []*TelemetryEndpoint
	ProtocolID         string
	Properties         map[string]interface{}
	ForkBlocks         []string
	BadBlocks          []string
	ConsensusEngine    string
}

Data defines the genesis file data formatted for trie storage

type Fields

type Fields struct {
	Raw     map[string]map[string]string      `json:"raw,omitempty"`
	Runtime map[string]map[string]interface{} `json:"runtime,omitempty"`
}

Fields stores genesis raw data, and human readable runtime data

type Genesis

type Genesis struct {
	Name               string                 `json:"name"`
	ID                 string                 `json:"id"`
	ChainType          string                 `json:"chainType"`
	Bootnodes          []string               `json:"bootNodes"`
	TelemetryEndpoints []interface{}          `json:"telemetryEndpoints"`
	ProtocolID         string                 `json:"protocolId"`
	Genesis            Fields                 `json:"genesis"`
	Properties         map[string]interface{} `json:"properties"`
	ForkBlocks         []string               `json:"forkBlocks"`
	BadBlocks          []string               `json:"badBlocks"`
	ConsensusEngine    string                 `json:"consensusEngine"`
}

Genesis stores the data parsed from the genesis configuration file

func NewGenesisFromJSON

func NewGenesisFromJSON(file string, authCount int) (*Genesis, error)

NewGenesisFromJSON parses Human Readable JSON formatted genesis file.Name. If authCount > 0, then it keeps only `authCount` number of authorities for babe and grandpa.

func NewGenesisFromJSONRaw added in v0.2.0

func NewGenesisFromJSONRaw(file string) (*Genesis, error)

NewGenesisFromJSONRaw parses a JSON formatted genesis file

func NewGenesisSpecFromJSON added in v0.4.0

func NewGenesisSpecFromJSON(file string) (*Genesis, error)

NewGenesisSpecFromJSON returns a new Genesis (without raw fields) from a human-readable genesis file

func (*Genesis) GenesisData

func (g *Genesis) GenesisData() *Data

GenesisData formats genesis for trie storage

func (*Genesis) GenesisFields

func (g *Genesis) GenesisFields() Fields

GenesisFields returns the genesis fields including genesis raw data

func (*Genesis) IsRaw added in v0.4.0

func (g *Genesis) IsRaw() bool

IsRaw returns whether the genesis is raw or not

func (*Genesis) ToRaw added in v0.4.0

func (g *Genesis) ToRaw() error

ToRaw converts a non-raw genesis to a raw genesis

type TelemetryEndpoint added in v0.4.1

type TelemetryEndpoint struct {
	Endpoint  string
	Verbosity int
}

TelemetryEndpoint struct to hold telemetry endpoint information

Jump to

Keyboard shortcuts

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