genesis

package
v0.34.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 11 Imported by: 46

Documentation

Index

Constants

View Source
const DefaultProposalThreshold uint64 = 3
View Source
const ShortHashSuffixBytes = 3

How many bytes to take from the front of the GenesisDoc hash to append to the ChainName to form the ChainID. The idea is to avoid some classes of replay attack between chains with the same name.

Variables

Functions

func NewDeterministicGenesis added in v0.18.0

func NewDeterministicGenesis(seed int64) *deterministicGenesis

Generates deterministic pseudo-random genesis state

func PermissionsAccount added in v0.28.0

func PermissionsAccount(globalPerms permission.AccountPermissions) *acm.Account

Types

type Account added in v0.18.0

type Account struct {
	BasicAccount
	Name        string
	Permissions permission.AccountPermissions
}

func GenesisAccountFromAccount added in v0.18.0

func GenesisAccountFromAccount(name string, account *acm.Account) Account

func (*Account) AcmAccount added in v0.24.0

func (genesisAccount *Account) AcmAccount() *acm.Account

func (*Account) Clone added in v0.18.0

func (genesisAccount *Account) Clone() Account

Clone clones the genesis account

type BasicAccount

type BasicAccount struct {
	// Address is convenient to have in file for reference, but otherwise ignored since derived from PublicKey
	Address   crypto.Address
	PublicKey *crypto.PublicKey
	Amount    uint64
}

func (*BasicAccount) Clone

func (basicAccount *BasicAccount) Clone() BasicAccount

Clone clones the basic account

type GenesisDoc

type GenesisDoc struct {
	GenesisTime time.Time
	ChainName   string
	// Ordinarily we derive this from the genesis hash but to support explicit Ethereum ChainID it may be set
	ChainID           string          `json:",omitempty" toml:",omitempty"`
	AppHash           binary.HexBytes `json:",omitempty" toml:",omitempty"`
	Params            params          `json:",omitempty" toml:",omitempty"`
	Salt              []byte          `json:",omitempty" toml:",omitempty"`
	GlobalPermissions permission.AccountPermissions
	Accounts          []Account
	Validators        []Validator
	// contains filtered or unexported fields
}

func GenesisDocFromJSON

func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)

func MakeGenesisDocFromAccounts

func MakeGenesisDocFromAccounts(chainName string, salt []byte, genesisTime time.Time, accounts map[string]*acm.Account,
	validators map[string]*validator.Validator) *GenesisDoc

MakeGenesisDocFromAccounts takes a chainName and a slice of pointers to Account, and a slice of pointers to Validator to construct a GenesisDoc, or returns an error on failure. In particular MakeGenesisDocFromAccount uses the local time as a timestamp for the GenesisDoc.

func (*GenesisDoc) GetChainID added in v0.31.1

func (genesisDoc *GenesisDoc) GetChainID() string

func (*GenesisDoc) GlobalPermissionsAccount added in v0.28.0

func (genesisDoc *GenesisDoc) GlobalPermissionsAccount() *acm.Account

func (*GenesisDoc) Hash added in v0.18.0

func (genesisDoc *GenesisDoc) Hash() binary.HexBytes

func (*GenesisDoc) JSONBytes added in v0.18.0

func (genesisDoc *GenesisDoc) JSONBytes() ([]byte, error)

JSONBytes returns the JSON canonical bytes for a given GenesisDoc or an error.

func (*GenesisDoc) JSONString added in v0.20.0

func (genesisDoc *GenesisDoc) JSONString() string

func (*GenesisDoc) ShortHash added in v0.18.0

func (genesisDoc *GenesisDoc) ShortHash() []byte

type Validator added in v0.18.0

type Validator struct {
	BasicAccount
	Name     string
	UnbondTo []BasicAccount
}

func (*Validator) Clone added in v0.18.0

func (gv *Validator) Clone() Validator

Clone clones the genesis validator

func (*Validator) Validator added in v0.18.0

func (gv *Validator) Validator() validator.Validator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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