networkbuilder

package
v0.14.1-0...-8b31b97 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const ValidatorSetNilErrorMessage = "validator set is nil in genesis and still empty after InitChain"

Variables

This section is empty.

Functions

func ConfigSave

func ConfigSave(c *Config) error

ConfigSave saves the current state of Config.

Types

type Account

type Account struct {
	Name     string
	Mnemonic string
	Coins    string
}

type Blockchain

type Blockchain struct {
	// contains filtered or unexported fields
}

func (*Blockchain) Cleanup

func (b *Blockchain) Cleanup() error

Cleanup closes the event bus and cleanups everything related to installed blockchain.

func (*Blockchain) Create

func (b *Blockchain) Create(ctx context.Context) error

Create submits Genesis to SPN to announce a new network.

func (*Blockchain) CreateAccount

func (b *Blockchain) CreateAccount(ctx context.Context, account chain.Account) (chain.Account, error)

func (*Blockchain) Info

func (b *Blockchain) Info() (BlockchainInfo, error)

Info returns information about the blockchain.

func (*Blockchain) IssueGentx

func (b *Blockchain) IssueGentx(ctx context.Context, account chain.Account, proposal Proposal) (gentx jsondoc.Doc, err error)

IssueGentx creates a Genesis transaction for account with proposal.

func (*Blockchain) Join

func (b *Blockchain) Join(ctx context.Context, accountAddress, publicAddress string, coins types.Coins, gentx []byte, selfDelegation types.Coin) error

Join proposes a validator to a network.

address is the ip+port combination of a p2p address of a node (does not include id). https://docs.tendermint.com/master/spec/p2p/config.html.

type BlockchainInfo

type BlockchainInfo struct {
	Genesis          jsondoc.Doc
	Config           conf.Config
	RPCPublicAddress string
}

BlockchainInfo hold information about a Blokchain.

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is network builder.

func New

func New(spnclient *spn.Client, options ...Option) (*Builder, error)

New creates a Builder.

func (*Builder) AccountCreate

func (b *Builder) AccountCreate(name, mnemonic string) (spn.Account, error)

AccountCreate creates a new account in OS keyring.

func (*Builder) AccountExport

func (b *Builder) AccountExport(name, password string) (privateKey string, err error)

AccountExport exports an account in OS keyring with name and password.

func (*Builder) AccountGet

func (b *Builder) AccountGet(name string) (spn.Account, error)

AccountGet gets an account by name in OS keyring.

func (*Builder) AccountImport

func (b *Builder) AccountImport(name, privateKey, password string) error

AccountImport imports account to OS keyring with name, password and privateKey.

func (*Builder) AccountInUse

func (b *Builder) AccountInUse() (spn.Account, error)

AccountInUse gets the account in use while working with SPN.

func (*Builder) AccountList

func (b *Builder) AccountList() ([]spn.Account, error)

AccountList lists all accounts in OS keyring.

func (*Builder) AccountUse

func (b *Builder) AccountUse(name string) error

AccountUse sets the account to be used while working with SPN.

func (*Builder) ChainList

func (b *Builder) ChainList(ctx context.Context, options ...spn.ChainListOption) (chains []spn.Chain, nextPageKey []byte, err error)

ChainList lists summaries of chains

func (*Builder) Init

func (b *Builder) Init(ctx context.Context, chainID string, source SourceOption, options ...InitOption) (*Blockchain, error)

Init initializes blockchain from by source option and init options.

func (*Builder) LaunchInformation

func (b *Builder) LaunchInformation(ctx context.Context, chainID string) (spn.LaunchInformation, error)

LaunchInformation retrieves chain's launch information.

func (*Builder) ProposalGet

func (b *Builder) ProposalGet(ctx context.Context, chainID string, id int) (spn.Proposal, error)

ProposalGet retrieves a proposal on a chain by id.

func (*Builder) ProposalList

func (b *Builder) ProposalList(ctx context.Context, chainID string, options ...spn.ProposalListOption) ([]spn.Proposal, error)

ProposalList lists proposals on a chain by status.

func (*Builder) Propose

func (b *Builder) Propose(ctx context.Context, chainID string, proposals ...spn.ProposalOption) error

Propose proposes given proposals in batch for chainID by using SPN accountName.

func (*Builder) ShowChain

func (b *Builder) ShowChain(ctx context.Context, chainID string) (spn.Chain, error)

ShowChain shows details of a chain.

func (*Builder) SimulatedLaunchInformation

func (b *Builder) SimulatedLaunchInformation(ctx context.Context, chainID string, proposalIDs []int) (spn.LaunchInformation, error)

SimulatedLaunchInformation retrieves chain's simulated launch information from proposals to verify.

func (*Builder) StartChain

func (b *Builder) StartChain(ctx context.Context, chainID string, flags []string, options ...InitOption) error

StartChain downloads the final version version of Genesis on the first start or fails if Genesis has not finalized yet. After overwriting the downloaded Genesis on top of app's home dir, it starts blockchain by executing the start command on its appd binary with optionally provided flags.

func (*Builder) SubmitReviewals

func (b *Builder) SubmitReviewals(ctx context.Context, chainID string, reviewals ...spn.Reviewal) (gas uint64, broadcast func() error, err error)

SubmitReviewals submits reviewals for proposals in batch for chainID by using SPN accountName.

func (*Builder) VerifyProposals

func (b *Builder) VerifyProposals(ctx context.Context, chainID string, homeDir string, proposals []int, commandOut io.Writer) (bool, error)

VerifyProposals generates a genesis file from the current launch information and proposals to verify The function returns false if the generated genesis is invalid

type Config

type Config struct {
	// SPNAccount is the default spn account in use.
	SPNAccount string

	// FinalizedChains can be started without any further preparation.
	FinalizedChains []string
}

Config holds configuration about network builder's state.

func ConfigGet

func ConfigGet() (*Config, error)

ConfigGet retrieves the current state of Config.

func (*Config) IsChainMarkedFinalized

func (c *Config) IsChainMarkedFinalized(chainID string) bool

IsChainMarkedFinalized checks if chain marked as finalized.

func (*Config) MarkFinalized

func (c *Config) MarkFinalized(chainID string)

MarkFinalized marks chain as finalized.

type DataDirExistsError

type DataDirExistsError struct {
	ID   string
	Home string
}

func (DataDirExistsError) Error

func (e DataDirExistsError) Error() string

type InitOption

type InitOption func(*initOptions)

InitOption sets other initialization options.

func InitializationCLIHomePath

func InitializationCLIHomePath(cliHomePath string) InitOption

InitializationCLIHomePath provides a specific cli home path for the blockchain for the initialization

func InitializationHomePath

func InitializationHomePath(homePath string) InitOption

InitializationHomePath provides a specific home path for the blockchain for the initialization

func MustNotInitializedBefore

func MustNotInitializedBefore() InitOption

MustNotInitializedBefore makes the initialization process fail if data dir for the blockchain already exists.

type Option

type Option func(*Builder)

func CollectEvents

func CollectEvents(ev events.Bus) Option

CollectEvents collects events from Builder.

type Proposal

type Proposal struct {
	Validator chain.Validator
	Meta      ProposalMeta
}

Proposal holds proposal info of validator candidate to join to a network.

type ProposalMeta

type ProposalMeta struct {
	Website  string
	Identity string
	Details  string
}

type SourceOption

type SourceOption func(*initOptions)

SourceOption sets the source for blockchain.

func SourceChainID

func SourceChainID() SourceOption

SourceChainID makes source determined by the chain's id.

func SourceLocal

func SourceLocal(path string) SourceOption

SourceLocal uses a local git repo as source for the blockchain.

func SourceRemote

func SourceRemote(url string) SourceOption

SourceRemote sets the default branch on a remote as source for the blockchain.

func SourceRemoteBranch

func SourceRemoteBranch(url, branch string) SourceOption

SourceRemoteBranch sets the branch on a remote as source for the blockchain.

func SourceRemoteHash

func SourceRemoteHash(url, hash string) SourceOption

SourceRemoteHash uses a remote hash as source for the blockchain.

func SourceRemoteTag

func SourceRemoteTag(url, tag string) SourceOption

SourceRemoteTag sets the tag on a remote as source for the blockchain.

Jump to

Keyboard shortcuts

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