networkchain

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SPNCacheDirectory    = "spn"
	BinaryCacheDirectory = "binary-cache"
	BinaryCacheFilename  = "checksums.yml"
)
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) AccountBalance

func (c Chain) AccountBalance() sdk.Coins

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, cacheStorage cache.Storage) (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) CheckConfigVersion

func (c Chain) CheckConfigVersion() error

CheckConfigVersion checks that the config version is the latest.

func (Chain) CheckRequestChangeParam

func (c Chain) CheckRequestChangeParam(
	ctx context.Context,
	module,
	param string,
	value []byte,
) error

CheckRequestChangeParam builds the genesis for the chain from the launch approved requests.

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, cacheStorage cache.Storage) error

Init initializes blockchain by building the binaries and running the init command, creates the initial genesis of the chain, and sets 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) IsAccountBalanceFixed

func (c Chain) IsAccountBalanceFixed() bool

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

func (c Chain) Prepare(
	ctx context.Context,
	cacheStorage cache.Storage,
	gi networktypes.GenesisInformation,
	rewardsInfo networktypes.Reward,
	spnChainID string,
	lastBlockHeight,
	consumerUnbondingTime int64,
) error

Prepare prepares the chain to be launched from genesis information.

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,
	cacheStorage cache.Storage,
	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 CheckDependencies

func CheckDependencies() Option

CheckDependencies checks that cached Go dependencies of the chain have not been modified since they were downloaded. Dependencies are checked by running `go mod verify`.

func CollectEvents

func CollectEvents(ev events.Bus) Option

CollectEvents collects events from the chain.

func WithGenesisFromConfig

func WithGenesisFromConfig(genesisConfig string) Option

WithGenesisFromConfig provides a config file for the initial genesis of the chain blockchain.

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