Documentation
¶
Index ¶
- Constants
- type AlgodExitErrorCallback
- type AlgodStartArgs
- type KMDController
- func (kc KMDController) GetKMDPID() (pid int64, err error)
- func (kc KMDController) KMDClient() (kmdClient client.KMDClient, err error)
- func (kc *KMDController) SetKMDBinDir(binDir string)
- func (kc *KMDController) SetKMDDataDir(kmdDataDir string)
- func (kc *KMDController) StartKMD(args KMDStartArgs) (alreadyRunning bool, err error)
- func (kc *KMDController) StopKMD() (alreadyStopped bool, err error)
- type KMDStartArgs
- type LaggedStdIo
- type MissingDataDirError
- type NodeController
- func (nc NodeController) AlgodClient() (algodClient client.RestClient, err error)
- func (nc NodeController) Clone(targetDir string, copyLedger bool) (err error)
- func (nc *NodeController) FullStart(args NodeStartArgs) (algodAlreadyRunning, kmdAlreadyRunning bool, err error)
- func (nc NodeController) FullStop() error
- func (nc NodeController) GetAlgodPID() (pid int64, err error)
- func (nc NodeController) GetAlgodPath() string
- func (nc NodeController) GetConsensus() (config.ConsensusProtocols, error)
- func (nc NodeController) GetDataDir() string
- func (nc NodeController) GetGenesis() (bookkeeping.Genesis, error)
- func (nc NodeController) GetGenesisDir() (string, error)
- func (nc NodeController) GetHostAddress() (string, error)
- func (nc NodeController) GetListeningAddress() (string, error)
- func (nc NodeController) ServerURL() (url.URL, error)
- func (nc NodeController) SetConsensus(consensus config.ConsensusProtocols) error
- func (nc NodeController) Shutdown() error
- func (nc *NodeController) StartAlgod(args AlgodStartArgs) (alreadyRunning bool, err error)
- func (nc *NodeController) StopAlgod() (err error)
- type NodeNotRunningError
- type NodeStartArgs
Constants ¶
const ( // DefaultKMDDataDir is exported so tests can initialize it with config info DefaultKMDDataDir = "kmd-v0.5" // DefaultKMDDataDirPerms is exported so tests can initialize the default kmd data dir DefaultKMDDataDirPerms = 0700 )
const StdErrFilename = "algod-err.log"
StdErrFilename is the name of the file in <datadir> where stderr will be captured if not redirected to host
const StdOutFilename = "algod-out.log"
StdOutFilename is the name of the file in <datadir> where stdout will be captured if not redirected to host
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlgodExitErrorCallback ¶
type AlgodExitErrorCallback func(*NodeController, error)
AlgodExitErrorCallback is the callback function from the node controller that reports upstream in case there was a change with the algod running state.
type AlgodStartArgs ¶
type AlgodStartArgs struct { PeerAddress string ListenIP string RedirectOutput bool RunUnderHost bool TelemetryOverride string ExitErrorCallback AlgodExitErrorCallback }
AlgodStartArgs are the possible arguments for starting algod
type KMDController ¶
type KMDController struct {
// contains filtered or unexported fields
}
KMDController wraps directories and processes involved in running kmd
func MakeKMDController ¶
func MakeKMDController(kmdDataDir, binDir string) *KMDController
MakeKMDController initializes a KMDController
func (KMDController) GetKMDPID ¶
func (kc KMDController) GetKMDPID() (pid int64, err error)
GetKMDPID returns the PID from the kmd.pid file in the kmd data directory, or an error
func (KMDController) KMDClient ¶
func (kc KMDController) KMDClient() (kmdClient client.KMDClient, err error)
KMDClient reads an APIToken and netFile from the kmd dataDir, and then builds a KMDClient for the running kmd process
func (*KMDController) SetKMDBinDir ¶
func (kc *KMDController) SetKMDBinDir(binDir string)
SetKMDBinDir updates the KMDController for a binDir that contains `kmd`
func (*KMDController) SetKMDDataDir ¶
func (kc *KMDController) SetKMDDataDir(kmdDataDir string)
SetKMDDataDir updates the KMDController for a kmd data directory.
func (*KMDController) StartKMD ¶
func (kc *KMDController) StartKMD(args KMDStartArgs) (alreadyRunning bool, err error)
StartKMD spins up a kmd process and waits for it to begin
func (*KMDController) StopKMD ¶
func (kc *KMDController) StopKMD() (alreadyStopped bool, err error)
StopKMD reads the net file and kills the kmd process
type KMDStartArgs ¶
type KMDStartArgs struct {
TimeoutSecs uint64
}
KMDStartArgs are the possible arguments for starting kmd
type LaggedStdIo ¶
type LaggedStdIo struct { LinePrefix atomic.Value // of datatype string // contains filtered or unexported fields }
LaggedStdIo is an indirect wrapper around os.Stdin/os.Stdout/os.Stderr that prevents direct dependency which could be an issue when a caller panics, leaving the child processes alive and blocks for EOF.
func NewLaggedStdIo ¶
func NewLaggedStdIo(stdio interface{}, linePrefix string) *LaggedStdIo
NewLaggedStdIo creates a new instance of the LaggedStdIo. allowed stdio are limited to os.Stdin, os.Stdout and os.Stderr
func (*LaggedStdIo) Read ¶
func (s *LaggedStdIo) Read(p []byte) (n int, err error)
Read implmenents the io.Reader interface and redirecting the read request to the correct stdin pipe.
func (*LaggedStdIo) SetLinePrefix ¶
func (s *LaggedStdIo) SetLinePrefix(linePrefix string)
SetLinePrefix sets the line prefix that would be used during the write opeearion.
type MissingDataDirError ¶
type MissingDataDirError struct {
// contains filtered or unexported fields
}
MissingDataDirError thrown when StopAlgod is called but requested directory does not exist
func (*MissingDataDirError) Error ¶
func (e *MissingDataDirError) Error() string
type NodeController ¶
type NodeController struct { KMDController // contains filtered or unexported fields }
NodeController provides an object for controlling a specific algod node instance
func MakeNodeController ¶
func MakeNodeController(binDir, algodDataDir string) NodeController
MakeNodeController creates a NodeController representing a specific data directory (and an associated binary directory)
func (NodeController) AlgodClient ¶
func (nc NodeController) AlgodClient() (algodClient client.RestClient, err error)
AlgodClient attempts to build a client.RestClient for communication with the algod REST API, but fails if we can't find the net file
func (NodeController) Clone ¶
func (nc NodeController) Clone(targetDir string, copyLedger bool) (err error)
Clone creates a new DataDir based on the controller's DataDir; if copyLedger is true, we'll clone the ledger.sqlite file
func (*NodeController) FullStart ¶
func (nc *NodeController) FullStart(args NodeStartArgs) (algodAlreadyRunning, kmdAlreadyRunning bool, err error)
FullStart will start the kmd and algod, reporting of either process is already running
func (NodeController) FullStop ¶
func (nc NodeController) FullStop() error
FullStop stops both algod and kmd, if they're running
func (NodeController) GetAlgodPID ¶
func (nc NodeController) GetAlgodPID() (pid int64, err error)
GetAlgodPID returns the PID from the algod.pid file in the node's data directory, or an error
func (NodeController) GetAlgodPath ¶
func (nc NodeController) GetAlgodPath() string
GetAlgodPath provides read-only access to the controller's algod instance
func (NodeController) GetConsensus ¶
func (nc NodeController) GetConsensus() (config.ConsensusProtocols, error)
GetConsensus rebuild the consensus version from the data directroy
func (NodeController) GetDataDir ¶
func (nc NodeController) GetDataDir() string
GetDataDir provides read-only access to the controller's data directory
func (NodeController) GetGenesis ¶
func (nc NodeController) GetGenesis() (bookkeeping.Genesis, error)
GetGenesis returns the current genesis for our instance
func (NodeController) GetGenesisDir ¶
func (nc NodeController) GetGenesisDir() (string, error)
GetGenesisDir returns the current genesis directory for our instance
func (NodeController) GetHostAddress ¶
func (nc NodeController) GetHostAddress() (string, error)
GetHostAddress retrieves the REST address for the node from its algod.net file.
func (NodeController) GetListeningAddress ¶
func (nc NodeController) GetListeningAddress() (string, error)
GetListeningAddress retrieves the listening address from the algod-listen.net file for the node
func (NodeController) ServerURL ¶
func (nc NodeController) ServerURL() (url.URL, error)
ServerURL returns the appropriate URL for the node under control
func (NodeController) SetConsensus ¶
func (nc NodeController) SetConsensus(consensus config.ConsensusProtocols) error
SetConsensus applies a new consensus settings which would get deployed before any of the nodes starts
func (NodeController) Shutdown ¶
func (nc NodeController) Shutdown() error
Shutdown requests the node to shut itself down
func (*NodeController) StartAlgod ¶
func (nc *NodeController) StartAlgod(args AlgodStartArgs) (alreadyRunning bool, err error)
StartAlgod spins up an algod process and waits for it to begin
func (*NodeController) StopAlgod ¶
func (nc *NodeController) StopAlgod() (err error)
StopAlgod reads the net file and kills the algod process
type NodeNotRunningError ¶
type NodeNotRunningError struct {
// contains filtered or unexported fields
}
NodeNotRunningError thrown when StopAlgod is called but there is no running algod in requested directory
func (*NodeNotRunningError) Error ¶
func (e *NodeNotRunningError) Error() string
type NodeStartArgs ¶
type NodeStartArgs struct { AlgodStartArgs KMDStartArgs }
NodeStartArgs represents the possible arguments for starting the node processes