Documentation ¶
Overview ¶
Package helpers contains functions to help make the task of deploying a blockchain easier and faster
Index ¶
- func AllNewNodeExecCon(tn *testnet.TestNet, fn func(ssh.Client, *db.Server, ssh.Node) error) error
- func AllNewNodeExecConDR(tn *testnet.TestNet, fn func(ssh.Client, *db.Server, ssh.Node) error) error
- func AllNewNodeExecConSC(ad *testnet.Adjunct, fn func(ssh.Client, *db.Server, ssh.Node) error) error
- func AllNodeExecCon(tn *testnet.TestNet, fn func(ssh.Client, *db.Server, ssh.Node) error) error
- func AllNodeExecConSC(ad *testnet.Adjunct, fn func(ssh.Client, *db.Server, ssh.Node) error) error
- func AllServerExecCon(tn *testnet.TestNet, fn func(ssh.Client, *db.Server) error) error
- func AllServerExecConSC(ad *testnet.Adjunct, fn func(ssh.Client, *db.Server) error) error
- func CheckDeployFlag(details *db.DeploymentDetails, flag string) bool
- func CopyAllToServers(tn *testnet.TestNet, srcDst ...string) error
- func CopyBytesToAllNewNodes(tn *testnet.TestNet, dataDst ...string) error
- func CopyBytesToAllNewNodesSC(ad *testnet.Adjunct, dataDst ...string) error
- func CopyBytesToAllNodes(tn *testnet.TestNet, dataDst ...string) error
- func CopyBytesToAllNodesSC(ad *testnet.Adjunct, dataDst ...string) error
- func CopyToAllNewNodes(tn *testnet.TestNet, srcDst ...string) error
- func CopyToAllNewNodesDR(tn *testnet.TestNet, srcDst ...string) error
- func CopyToAllNewNodesSC(ad *testnet.Adjunct, srcDst ...string) error
- func CopyToAllNodes(tn *testnet.TestNet, srcDst ...string) error
- func CopyToAllNodesDR(tn *testnet.TestNet, srcDst ...string) error
- func CopyToAllNodesSC(ad *testnet.Adjunct, srcDst ...string) error
- func CreateConfigs(tn *testnet.TestNet, dest string, fn func(ssh.Node) ([]byte, error)) error
- func CreateConfigsNewNodes(tn *testnet.TestNet, dest string, fn func(ssh.Node) ([]byte, error)) error
- func CreateConfigsNewNodesSC(ad *testnet.Adjunct, dest string, fn func(ssh.Node) ([]byte, error)) error
- func CreateConfigsSC(ad *testnet.Adjunct, dest string, fn func(ssh.Node) ([]byte, error)) error
- func DefaultGetDefaultsFn(blockchain string) func() string
- func DefaultGetParamsFn(blockchain string) func() string
- func FetchPreGeneratedPrivateKeys(tn *testnet.TestNet) ([]string, error)
- func FetchPreGeneratedPublicKeys(tn *testnet.TestNet) ([]string, error)
- func FirstNodeExec(tn *testnet.TestNet, cmd string) (string, error)
- func GetBlockchainConfig(blockchain string, node int, file string, details *db.DeploymentDetails) ([]byte, error)
- func GetCommandExprs(tn *testnet.TestNet, node string) ([]string, error)
- func GetDefaults(details *db.DeploymentDetails, term string) (interface{}, bool)
- func GetFileDefault(details *db.DeploymentDetails, file string) (string, bool)
- func GetGlobalBlockchainConfig(tn *testnet.TestNet, file string) ([]byte, error)
- func GetProtocolGroup(tn *testnet.TestNet) (string, error)
- func GetStaticBlockchainConfig(blockchain string, file string) ([]byte, error)
- func HandleBlockchainConfig(blockchain string, data map[string]interface{}, out interface{}) error
- func JSONRPCAllNodes(tn *testnet.TestNet, call string, port int) ([]interface{}, error)
- func MkdirAllNewNodes(tn *testnet.TestNet, dir string) error
- func MkdirAllNodes(tn *testnet.TestNet, dir string) error
- func ScpAndDeferRemoval(client ssh.Client, buildState *state.BuildState, src string, dst string)
- func SetAlternativeCmdExprs(tn *testnet.TestNet, alts ...string)
- func SetFunctionalityGroup(tn *testnet.TestNet, name string)
- func SetProtocolGroup(tn *testnet.TestNet, name string)
- func SingleCp(client ssh.Client, buildState *state.BuildState, node ssh.Node, data []byte, ...) error
- type KeyMaster
- func (km *KeyMaster) AddGenerator(gen func(client ssh.Client) (util.KeyPair, error))
- func (km *KeyMaster) GenerateKeyPair(client ssh.Client) (util.KeyPair, error)
- func (km *KeyMaster) GetKeyPair(client ssh.Client) (util.KeyPair, error)
- func (km *KeyMaster) GetMappedKeyPairs(args []string, client ssh.Client) (map[string]util.KeyPair, error)
- func (km *KeyMaster) GetServerKeyPairs(tn *testnet.TestNet) (map[string]util.KeyPair, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllNewNodeExecCon ¶
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 ¶
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 ¶
AllNodeExecConSC is AllNodeExecCon but executes only for sidecar nodes
func AllServerExecCon ¶
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 ¶
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 ¶
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 ¶
CopyBytesToAllNewNodes is CopyBytesToAllNodes but only operates on newly built nodes
func CopyBytesToAllNewNodesSC ¶
CopyBytesToAllNewNodesSC is CopyBytesToAllNewNodes but only operates on sidecar nodes
func CopyBytesToAllNodes ¶
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 ¶
CopyBytesToAllNodesSC is CopyBytesToAllNodes but only operates on sidecar nodes
func CopyToAllNewNodes ¶
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
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 ¶
CopyToAllNewNodesSC is CopyToAllNewNodes for side cars
func CopyToAllNodes ¶
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
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 ¶
CopyToAllNodesSC is CopyToAllNodes for side cars
func CreateConfigs ¶
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 ¶
CreateConfigsSC is CreateConfigs but it only operates on side cars
func DefaultGetDefaultsFn ¶
DefaultGetDefaultsFn creates the default function for getting a blockchains default parameters
func DefaultGetParamsFn ¶
DefaultGetParamsFn creates the default function for getting a blockchains parameters
func FetchPreGeneratedPrivateKeys ¶ added in v1.8.16
FetchPreGeneratedPrivateKeys gets the pregenerated private keys for a blockchain from privatekeys.json
func FetchPreGeneratedPublicKeys ¶ added in v1.8.16
FetchPreGeneratedPublicKeys gets the pregenerated public keys for a blockchain from publickeys.json
func FirstNodeExec ¶ added in v1.8.16
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
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
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
GetProtocolGroup gets the protocol group for the testnet
func GetStaticBlockchainConfig ¶
GetStaticBlockchainConfig fetches a static file resource for a blockchain, which will never change
func HandleBlockchainConfig ¶
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
JSONRPCAllNodes calls a JSON RPC call on all nodes and then returns the result
func MkdirAllNewNodes ¶
MkdirAllNewNodes makes a dir on all new nodes
func MkdirAllNodes ¶
MkdirAllNodes makes a dir on all nodes
func ScpAndDeferRemoval ¶
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
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
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
SetProtocolGroup sets the protocol group for the testnet
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 ¶
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 ¶
AddGenerator sets the backup key generator function for km KeyMaster
func (*KeyMaster) GenerateKeyPair ¶
GenerateKeyPair generates a new key pair if a generator function has been provided
func (*KeyMaster) GetKeyPair ¶
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