Documentation ¶
Overview ¶
Package coin defines functions common to all masternode-based coins. Additionally, each coin which is implemented in this program will register itself with the coin package so that we can use this as the generic communication point for the client application. This draws a lot of inspiration from the `image` libraries in golang.
Index ¶
- Variables
- func Command(cli *types.CLI, cmd string, opts []string) error
- func CreateConfFile(fp string, m map[string]string) error
- func DirExists(fp string) bool
- func ExecCmd(cmd string, args ...string) (io.ReadCloser, io.ReadCloser, error)
- func FileExists(fp string) bool
- func GetRandomHex(size int) string
- func HomeDir() string
- func IsRegistered(name string) bool
- func LoadConfFile(fp string) (map[string]string, error)
- func RegisterCoin(name string, port, rpcPort int, daemonBin, statusBin, configFile string, ...) error
- func RegisteredCoins() []string
- type BootstrapDownloader
- type Coin
- func (c *Coin) DoJSONRPCCommand(method string, params []interface{}) (*JSONRPCResponse, error)
- func (c *Coin) DownloadBootstrap(args []string, override *types.Bootstrap) error
- func (c *Coin) DownloadWallet(args []string, override *types.Download) error
- func (c *Coin) GetBinPath() string
- func (c *Coin) GetConfFilePath() string
- func (c *Coin) GetConfig() map[string]string
- func (c *Coin) GetConfigValue(key string) string
- func (c *Coin) GetDaemonBinPath() string
- func (c *Coin) GetDataPath() string
- func (c *Coin) GetName() string
- func (c *Coin) GetOpaque() interface{}
- func (c *Coin) GetPort() int
- func (c *Coin) GetRPCPort() int
- func (c *Coin) PrintCoinInfo(prefix string) error
- func (c *Coin) StartDaemon() error
- func (c *Coin) UpdateDynamic(wallet, subpath, data string) error
- type CoinFunc
- type CoinState
- type FunctionMap
- type JSONRPCError
- type JSONRPCResponse
- type ProgressTracker
- type WalletDownloader
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Command ¶
Command executes a given coin's (specified by `name`), `cmd` function if one was registered. If the function was nil, then it has no implementation and we do nothing. If the command was not found we return an error.
func CreateConfFile ¶
CreateConfFile generates a config file with the specified key-value pairs in `m`.
func ExecCmd ¶
func ExecCmd(cmd string, args ...string) (io.ReadCloser, io.ReadCloser, error)
ExecCmd takes a executable at path specified by `cmd`, where `args` are a set of options to execute the command with. Returns the stdout, stderr and any errors from trying to execute the command. This function blocks until the command finishes.
func FileExists ¶
FileExists returns true if `fp` is a file and exists.
func IsRegistered ¶
IsRegistered returns true if the coin specified by `name` is known to the gomn system.
func LoadConfFile ¶
LoadConfFile returns a map of key-value pairs found in a `.conf` file pointed to by `fp`.
func RegisterCoin ¶
func RegisterCoin( name string, port, rpcPort int, daemonBin, statusBin, configFile string, defWalletPath, defBinSubPath, defDataPath string, wdl *WalletDownloader, bdl *BootstrapDownloader, fnMap *FunctionMap, opaque interface{}) error
func RegisteredCoins ¶
func RegisteredCoins() []string
RegisteredCoins returns a list of coins that the tool knows how to configure.
Types ¶
type BootstrapDownloader ¶
type BootstrapDownloader struct { DownloadURL string // URL to fetch bootstrap archive CompressionType string // type of compression ["tar.gz", "zip", "none"] }
func NewBootstrapDownloader ¶
func NewBootstrapDownloader(url, ctype string) *BootstrapDownloader
NewBootstrapDownloader returns a new instance of a bootstrap downloader.
func (*BootstrapDownloader) DownloadToPath ¶
func (b *BootstrapDownloader) DownloadToPath(bootstrapPath string, override *types.Bootstrap) error
DownloadToPath grabs a archive from a web url defined in `b` and extracts the file if needed into `bootstrapPath`.
type Coin ¶
type Coin struct { // Coin specific functions to invoke! FnMap *FunctionMap // contains filtered or unexported fields }
Coin represents all things needed to setup / interact-with or monitor a given coin's masternode.
func GetCoinByName ¶
func (*Coin) DoJSONRPCCommand ¶
func (c *Coin) DoJSONRPCCommand(method string, params []interface{}) (*JSONRPCResponse, error)
DoJSONRPCCommand accepts a `method` and a list of values in `params` which will be sent over JSON RPC to the corresponding coin's daemon.
func (*Coin) DownloadBootstrap ¶
func (*Coin) DownloadWallet ¶
func (*Coin) GetBinPath ¶
func (*Coin) GetConfFilePath ¶
func (*Coin) GetConfigValue ¶
GetConfigValue returns the value for a given key in the config file. Returns an empty string if the key is not found.
func (*Coin) GetDaemonBinPath ¶
func (*Coin) GetDataPath ¶
func (*Coin) GetRPCPort ¶
func (*Coin) PrintCoinInfo ¶
PrintCoinInfo is a common function that can be used by all coin implementations to print common info for a given coin.
func (*Coin) StartDaemon ¶
func (*Coin) UpdateDynamic ¶
type CoinState ¶
type CoinState struct {
// contains filtered or unexported fields
}
CoinState represents a collection of dynamic coin properties that are only known at run-time.
type FunctionMap ¶
type FunctionMap struct { InfoFn CoinFunc DownloadFn CoinFunc BootstrapFn CoinFunc ConfigureFn CoinFunc GetInfoFn CoinFunc }
func (*FunctionMap) Validate ¶
func (fm *FunctionMap) Validate(c *Coin) error
type JSONRPCError ¶
type JSONRPCResponse ¶
type JSONRPCResponse struct { ID int64 `json:"id,omitempty"` Result map[string]interface{} `json:"result,omitempty"` Error JSONRPCError `json:"error,omitempty"` }
type ProgressTracker ¶
type ProgressTracker struct {
// contains filtered or unexported fields
}
ProgressTracker implements the Write function so we can have it track the number of bytes being written.
func NewProgressTracker ¶
func NewProgressTracker(total int64) *ProgressTracker
NewProgressTracker returns a instance that implements a writer interface so we can track progress of a download via a tee reader in the caller.
type WalletDownloader ¶
type WalletDownloader struct { Version string // version of the wallet DownloadURL string // url to fetch the wallet CompressionType string // type of compression ["tar.gz", "zip", "none"] Sha256sum string // shasum for the download PathToBins string // path from destination -> binary directory }
WalletDownloader is a per-coin wallet fetcher.
func NewWalletDownloader ¶
func NewWalletDownloader(v, url, ct, sha string) *WalletDownloader
NewWalletDownloader returns a new instance of a wallet downloader.
func (*WalletDownloader) DownloadToPath ¶
func (w *WalletDownloader) DownloadToPath(walletPath string, override *types.Download) error
DownloadToPath grabs the underlying wallet file, and checks its sha256sum to verify that it is indeed the expected file. If so, it extracts the contents to the appropriate