helpers

package
v1.8.17 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package helpers contains functions to help make the task of deploying a blockchain easier and faster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllNewNodeExecCon

func AllNewNodeExecCon(tn *testnet.TestNet, fn func(ssh.Client, *db.Server, ssh.Node) error) error

AllNewNodeExecCon is AllNodeExecCon but executes only for new nodes

func AllNewNodeExecConDR added in v1.8.11

func AllNewNodeExecConDR(tn *testnet.TestNet, fn func(ssh.Client, *db.Server, ssh.Node) error) error

AllNewNodeExecConDR is AllNodeExecCon but executes only for new nodes, but only returns the error, doesn't report it to the build state automatically. (You most likely do NOT want this)

func AllNewNodeExecConSC

func AllNewNodeExecConSC(ad *testnet.Adjunct, fn func(ssh.Client, *db.Server, ssh.Node) error) error

AllNewNodeExecConSC is AllNewNodeExecCon but executes only for sidecar nodes

func AllNodeExecCon

func AllNodeExecCon(tn *testnet.TestNet, fn func(ssh.Client, *db.Server, ssh.Node) error) error

AllNodeExecCon executes fn for every node concurrently. Will return once all of the calls to fn have been completely. Each call to fn is provided with, in order, the relevant ssh client, the server where the node exists, the local number of that node on the server and the absolute number of the node in the testnet. If any of the calls to fn return a non-nil error value, one of those errors will be returned. Currently there is no guarantee as to which one, however this should be implemented in the future.

func AllNodeExecConSC

func AllNodeExecConSC(ad *testnet.Adjunct, fn func(ssh.Client, *db.Server, ssh.Node) error) error

AllNodeExecConSC is AllNodeExecCon but executes only for sidecar nodes

func AllServerExecCon

func AllServerExecCon(tn *testnet.TestNet, fn func(ssh.Client, *db.Server) error) error

AllServerExecCon executes fn for every server in the testnet. Is sementatically similar to AllNodeExecCon. Every call to fn is provided with the relevant ssh client and server object.

func AllServerExecConSC

func AllServerExecConSC(ad *testnet.Adjunct, fn func(ssh.Client, *db.Server) error) error

AllServerExecConSC is like AllServerExecCon but for side cars

func CheckDeployFlag

func CheckDeployFlag(details *db.DeploymentDetails, flag string) bool

CheckDeployFlag checks for the presence of an extras flag.

func CopyAllToServers

func CopyAllToServers(tn *testnet.TestNet, srcDst ...string) error

CopyAllToServers copies all of the src files to all of the servers within the given testnet. This can handle multiple pairs in form of ...,source,destination,source2,destination2

func CopyBytesToAllNewNodes

func CopyBytesToAllNewNodes(tn *testnet.TestNet, dataDst ...string) error

CopyBytesToAllNewNodes is CopyBytesToAllNodes but only operates on newly built nodes

func CopyBytesToAllNewNodesSC

func CopyBytesToAllNewNodesSC(ad *testnet.Adjunct, dataDst ...string) error

CopyBytesToAllNewNodesSC is CopyBytesToAllNewNodes but only operates on sidecar nodes

func CopyBytesToAllNodes

func CopyBytesToAllNodes(tn *testnet.TestNet, dataDst ...string) error

CopyBytesToAllNodes functions similarly to CopyToAllNodes, except it operates on data and dst pairs instead of src and dest pairs, so you can just pass data directly to all of the nodes without having to call buildState.Write first.

func CopyBytesToAllNodesSC

func CopyBytesToAllNodesSC(ad *testnet.Adjunct, dataDst ...string) error

CopyBytesToAllNodesSC is CopyBytesToAllNodes but only operates on sidecar nodes

func CopyToAllNewNodes

func CopyToAllNewNodes(tn *testnet.TestNet, srcDst ...string) error

CopyToAllNewNodes copies files written with BuildState's write function over to all of the newly built nodes. Can handle multiple files, in pairs of src and dst

func CopyToAllNewNodesDR added in v1.8.11

func CopyToAllNewNodesDR(tn *testnet.TestNet, srcDst ...string) error

CopyToAllNewNodesDR copies files written with BuildState's write function over to all of the newly built nodes. Can handle multiple files, in pairs of src and dst. DR means it doesn't report the error to build state.

func CopyToAllNewNodesSC

func CopyToAllNewNodesSC(ad *testnet.Adjunct, srcDst ...string) error

CopyToAllNewNodesSC is CopyToAllNewNodes for side cars

func CopyToAllNodes

func CopyToAllNodes(tn *testnet.TestNet, srcDst ...string) error

CopyToAllNodes copies files written with BuildState's write function over to all of the nodes. Can handle multiple files, in pairs of src and dst

func CopyToAllNodesDR added in v1.8.11

func CopyToAllNodesDR(tn *testnet.TestNet, srcDst ...string) error

CopyToAllNodesDR copies files written with BuildState's write function over to all of the nodes. Can handle multiple files, in pairs of src and dst. DR means it doesn't report the error to build state.

func CopyToAllNodesSC

func CopyToAllNodesSC(ad *testnet.Adjunct, srcDst ...string) error

CopyToAllNodesSC is CopyToAllNodes for side cars

func CreateConfigs

func CreateConfigs(tn *testnet.TestNet, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigs allows for individual generation of configuration files with error propagation. For each node, fn will be called, with (Server ID, local node number, absolute node number), and it will expect to have the configuration file returned or error.

func CreateConfigsNewNodes

func CreateConfigsNewNodes(tn *testnet.TestNet, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigsNewNodes is CreateConfigs but it only operates on new nodes

func CreateConfigsNewNodesSC

func CreateConfigsNewNodesSC(ad *testnet.Adjunct, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigsNewNodesSC is CreateConfigsNewNodes but it only operates on side cars

func CreateConfigsSC

func CreateConfigsSC(ad *testnet.Adjunct, dest string, fn func(ssh.Node) ([]byte, error)) error

CreateConfigsSC is CreateConfigs but it only operates on side cars

func DefaultGetDefaultsFn

func DefaultGetDefaultsFn(blockchain string) func() string

DefaultGetDefaultsFn creates the default function for getting a blockchains default parameters

func DefaultGetParamsFn

func DefaultGetParamsFn(blockchain string) func() string

DefaultGetParamsFn creates the default function for getting a blockchains parameters

func FetchPreGeneratedPrivateKeys added in v1.8.16

func FetchPreGeneratedPrivateKeys(tn *testnet.TestNet) ([]string, error)

FetchPreGeneratedPrivateKeys gets the pregenerated private keys for a blockchain from privatekeys.json

func FetchPreGeneratedPublicKeys added in v1.8.16

func FetchPreGeneratedPublicKeys(tn *testnet.TestNet) ([]string, error)

FetchPreGeneratedPublicKeys gets the pregenerated public keys for a blockchain from publickeys.json

func FirstNodeExec added in v1.8.16

func FirstNodeExec(tn *testnet.TestNet, cmd string) (string, error)

FirstNodeExec runs a command on the first node

func GetBlockchainConfig

func GetBlockchainConfig(blockchain string, node int, file string, details *db.DeploymentDetails) ([]byte, error)

GetBlockchainConfig fetches dynamic config template files for the blockchain. Should be used in most cases instead of GetStaticBlockchainConfig as it provides the user the functionality for `-t..` in the build command for the CLI

func GetCommandExprs added in v1.8.16

func GetCommandExprs(tn *testnet.TestNet, node string) ([]string, error)

GetCommandExprs get the command expressions to match on to find the main blockchain process

func GetDefaults

func GetDefaults(details *db.DeploymentDetails, term string) (interface{}, bool)

GetDefaults get any available default value for a given term. will be nil,false if it is not found

func GetFileDefault

func GetFileDefault(details *db.DeploymentDetails, file string) (string, bool)

GetFileDefault gets the default value for a file if it exists in the extras

func GetGlobalBlockchainConfig added in v1.8.16

func GetGlobalBlockchainConfig(tn *testnet.TestNet, file string) ([]byte, error)

GetGlobalBlockchainConfig fetches a static file resource for a blockchain, which will be the same for all of the nodes

func GetProtocolGroup added in v1.8.16

func GetProtocolGroup(tn *testnet.TestNet) (string, error)

GetProtocolGroup gets the protocol group for the testnet

func GetStaticBlockchainConfig

func GetStaticBlockchainConfig(blockchain string, file string) ([]byte, error)

GetStaticBlockchainConfig fetches a static file resource for a blockchain, which will never change

func HandleBlockchainConfig

func HandleBlockchainConfig(blockchain string, data map[string]interface{}, out interface{}) error

HandleBlockchainConfig handles the creation of a blockchain configuration from the defaults and given data from the deployment details

func JSONRPCAllNodes added in v1.8.16

func JSONRPCAllNodes(tn *testnet.TestNet, call string, port int) ([]interface{}, error)

JSONRPCAllNodes calls a JSON RPC call on all nodes and then returns the result

func MkdirAllNewNodes

func MkdirAllNewNodes(tn *testnet.TestNet, dir string) error

MkdirAllNewNodes makes a dir on all new nodes

func MkdirAllNodes

func MkdirAllNodes(tn *testnet.TestNet, dir string) error

MkdirAllNodes makes a dir on all nodes

func ScpAndDeferRemoval

func ScpAndDeferRemoval(client ssh.Client, buildState *state.BuildState, src string, dst string)

ScpAndDeferRemoval Copy a file over to a server, and then defer it for removal after the build is completed

func SetAlternativeCmdExprs added in v1.8.16

func SetAlternativeCmdExprs(tn *testnet.TestNet, alts ...string)

SetAlternativeCmdExprs allows you to have your protocol support restart and related functionality if the blockchain main process looks diferent from the actual process.

func SetFunctionalityGroup added in v1.8.16

func SetFunctionalityGroup(tn *testnet.TestNet, name string)

SetFunctionalityGroup allows you to mark your protocol as being part of a functionality group. Most common group right now is eth

func SetProtocolGroup added in v1.8.16

func SetProtocolGroup(tn *testnet.TestNet, name string)

SetProtocolGroup sets the protocol group for the testnet

func SingleCp

func SingleCp(client ssh.Client, buildState *state.BuildState, node ssh.Node, data []byte, dest string) error

SingleCp copies over data to the given dest on node localNodeID.

Types

type KeyMaster

type KeyMaster struct {
	//PrivateKeys contains the static pool of private keys
	PrivateKeys []string
	//PublicKeys contains the static pool of private keys.
	PublicKeys []string
	// contains filtered or unexported fields
}

KeyMaster is a static resource key manager Uses keys stored in the blockchains resource directory, so that keys can remain consistent among builds and also to save time on builds where a large number of keys are needed. Note: This is not thread safe and may need external synchronization.

func NewKeyMaster

func NewKeyMaster(tn *testnet.TestNet) (*KeyMaster, error)

NewKeyMaster creates a new KeyMaster using the provided deployment details and blockchain. Currently details is not used, but in the future, it should be used to allow the user to provide their own static keys to be used in the pool.

func (*KeyMaster) AddGenerator

func (km *KeyMaster) AddGenerator(gen func(client ssh.Client) (util.KeyPair, error))

AddGenerator sets the backup key generator function for km KeyMaster

func (*KeyMaster) GenerateKeyPair

func (km *KeyMaster) GenerateKeyPair(client ssh.Client) (util.KeyPair, error)

GenerateKeyPair generates a new key pair if a generator function has been provided

func (*KeyMaster) GetKeyPair

func (km *KeyMaster) GetKeyPair(client ssh.Client) (util.KeyPair, error)

GetKeyPair fetches a key pair, will use up keys in the static pool until it runs out, if it runs out, it will use the given generator to create new keys

func (*KeyMaster) GetMappedKeyPairs

func (km *KeyMaster) GetMappedKeyPairs(args []string, client ssh.Client) (map[string]util.KeyPair, error)

GetMappedKeyPairs returns key pairs mapped to arbitrary string values. Useful for named key pairs

func (*KeyMaster) GetServerKeyPairs

func (km *KeyMaster) GetServerKeyPairs(tn *testnet.TestNet) (map[string]util.KeyPair, error)

GetServerKeyPairs is DEPRECATED, but maps the ip addresses of nodes to their own key pair

Jump to

Keyboard shortcuts

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