networkchain

package
v0.0.0-...-9032b55 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SPNCacheDirectory    = "spn"
	BinaryCacheDirectory = "binary-cache"
	BinaryCacheFilename  = "checksums.yml"
)
View Source
const (
	ListeningTimeout            = time.Minute * 1
	ValidatorSetNilErrorMessage = "validator set is nil in genesis and still empty after InitChain"
)
View Source
const (
	HTTPTunnelChisel = "chisel"
)
View Source
const SPNConfigFile = "spn.yml"

Variables

This section is empty.

Functions

func ChainHome

func ChainHome(launchID uint64) (path string)

ChainHome returns the default home dir used for a chain from SPN.

func IsChainHomeExist

func IsChainHomeExist(launchID uint64) (path string, ok bool, err error)

IsChainHomeExist checks if a home with the provided launchID already exist.

func SetSPNConfig

func SetSPNConfig(config Config, path string) error

Types

type Binary

type Binary struct {
	LaunchID  uint64
	BuildHash string
}

Binary associates launch id with build hash where build hash is sha256(binary, source)

type BinaryCacheList

type BinaryCacheList struct {
	CachedBinaries []Binary `yaml:"cached_binaries"`
}

func (*BinaryCacheList) Get

func (l *BinaryCacheList) Get(launchID uint64) (string, bool)

func (*BinaryCacheList) Set

func (l *BinaryCacheList) Set(launchID uint64, buildHash string)

type Chain

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

Chain represents a network blockchain and lets you interact with its source code and binary.

func New

func New(ctx context.Context, ar cosmosaccount.Registry, source SourceOption, options ...Option) (*Chain, error)

New initializes a network blockchain from source and options.

func (Chain) AppTOMLPath

func (c Chain) AppTOMLPath() (string, error)

func (Chain) BinaryName

func (c Chain) BinaryName() (name string, err error)

func (*Chain) Build

func (c *Chain) Build(ctx context.Context) (binaryName string, err error)

Build builds chain sources, also checks if source was already built

func (*Chain) CacheBinary

func (c *Chain) CacheBinary(launchID uint64) error

CacheBinary caches last built chain binary associated with launch id

func (Chain) ChainID

func (c Chain) ChainID() (string, error)

func (Chain) ConfigTOMLPath

func (c Chain) ConfigTOMLPath() (string, error)

func (Chain) DefaultGentxPath

func (c Chain) DefaultGentxPath() (path string, err error)

func (Chain) GenesisPath

func (c Chain) GenesisPath() (path string, err error)

func (Chain) GentxsPath

func (c Chain) GentxsPath() (path string, err error)

func (Chain) Home

func (c Chain) Home() (path string, err error)

func (Chain) ID

func (c Chain) ID() (string, error)

func (*Chain) ImportAccount

func (c *Chain) ImportAccount(ctx context.Context, name string) (string, error)

ImportAccount imports an account from Starport into the chain. we first export the account into a temporary key file and import it with the chain CLI.

func (*Chain) Init

func (c *Chain) Init(ctx context.Context) error

Init initializes blockchain by building the binaries and running the init command and create the initial genesis of the chain, and set up a validator key

func (Chain) InitAccount

func (c Chain) InitAccount(ctx context.Context, v chain.Validator, accountName string) (string, error)

InitAccount initializes an account for the blockchain and issue a gentx in config/gentx/gentx.json

func (Chain) IsHomeDirExist

func (c Chain) IsHomeDirExist() (ok bool, err error)

func (Chain) Name

func (c Chain) Name() string

func (Chain) NodeID

func (c Chain) NodeID(ctx context.Context) (string, error)

NodeID returns the chain node id

func (Chain) Prepare

Prepare prepares the chain to be launched from genesis information

func (Chain) ResetGenesisTime

func (c Chain) ResetGenesisTime() error

ResetGenesisTime reset the chain genesis time

func (*Chain) SPNConfigPath

func (c *Chain) SPNConfigPath() (string, error)

func (Chain) SetHome

func (c Chain) SetHome(home string)

func (Chain) SimulateRequests

func (c Chain) SimulateRequests(ctx context.Context, gi networktypes.GenesisInformation, reqs []networktypes.Request) (err error)

SimulateRequests simulates the genesis creation and the start of the network from the provided requests

func (Chain) SourceHash

func (c Chain) SourceHash() string

func (Chain) SourceURL

func (c Chain) SourceURL() string

type Config

type Config struct {
	TunneledPeers []TunneledPeer `json:"tunneled_peers" yaml:"tunneled_peers"`
}

func GetSPNConfig

func GetSPNConfig(path string) (conf Config, err error)

type Option

type Option func(*Chain)

Option sets other initialization options.

func CollectEvents

func CollectEvents(ev events.Bus) Option

CollectEvents collects events from the chain.

func WithGenesisFromURL

func WithGenesisFromURL(genesisURL string) Option

WithGenesisFromURL provides a genesis url for the initial genesis of the chain blockchain

func WithHome

func WithHome(path string) Option

WithHome provides a specific home path for the blockchain for the initialization.

func WithKeyringBackend

func WithKeyringBackend(keyringBackend chaincmd.KeyringBackend) Option

WithKeyringBackend provides the keyring backend to use to initialize the blockchain

type SourceOption

type SourceOption func(*Chain)

SourceOption sets the source for blockchain.

func SourceLaunch

func SourceLaunch(launch networktypes.ChainLaunch) SourceOption

SourceLaunch returns a source option for initializing a chain from a launch

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.

type TunneledPeer

type TunneledPeer struct {
	// Name represents tunnel type e.g. "chisel"
	Name string `json:"name" yaml:"name"`

	// Address represents http address of the tunnel e.g. "https://tendermint-starport-i5e75cplx02.ws-eu31.gitpod.io/"
	Address string `json:"address" yaml:"address"`

	// NodeID tendermint node id of the node behind the tunnel e.g. "e6a59e37b2761f26a21c9168f78a7f2b07c120c7"
	NodeID string `json:"node_id" yaml:"node_id"`

	// LocalPort specifies port which has to be used for local tunnel client
	LocalPort string `json:"local_port" yaml:"local_port"`
}

TunneledPeer represents http tunnel to a peer which can't be reached via regular tcp connection

Jump to

Keyboard shortcuts

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