utils

package
v0.0.0-...-832449c Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogFile *os.File

LogFile - Where the logs are stored

View Source
var LogLevel int

LogLevel - What kind of logs to show (1 = Debug and above, 2 = Info and above, 3 = Warnings and above, 4 = Fatal)

View Source
var RequestTimeout int

RequestTimeout - Request timeout in seconds

Functions

func AskPassphrase

func AskPassphrase() string

AskPassphrase - prompt user for passphrase.

func CachePassphrase

func CachePassphrase(passphrase string)

CachePassphrase - cache passphrase so user's don't have to retype it every time in the same command.

func CheckBalance

func CheckBalance(address, symbol string) (float64, error)

CheckBalance - check SYMBOL balance of account DEPRECATED

func CheckTx

func CheckTx(tx string) (bool, error)

CheckTx - check status of tx. Perform a single check on a tx. DEPRECATED

func GetIP

func GetIP() (string, error)

GetIP - Retrieve the current machine's external IPv4 address using multiple ip API's. DEPRECATED

func HandleError

func HandleError(err error, msg, path string) error

HandleError - custom error handler for the CLI. Uses ResponseError as a means of keeping 2 seperate error messages. UserMessage is a message to display to a user when an error occurs. LogError is a message to log or display to a developer. Path is the error path which is up to the developer to include.

func NewPassphrase

func NewPassphrase() string

NewPassphrase - prompts user for new passphrase and confirms it.

func OpenAccount

func OpenAccount() (bool, error)

OpenAccount - open/unlock an account

func PrintError

func PrintError(err error)

PrintError - print and logs ReponseError's. Use this to println the UserMessage and log the LogError with correct path.

func SendRequest

func SendRequest(requestType, url string, data interface{}) (string, error)

SendRequest - custom function to make sending api requests less of a pain in the arse.

func SetLogLevel

func SetLogLevel(level int)

SetLogLevel - Sets the appropriate logging level. 1 = Debug < , 2 = Info <, 3 = Warning <, 4 = Fatal.

func SetupLogger

func SetupLogger() error

SetupLogger - Clears the previous file, and creates log file ready for writing

func Version

func Version()

Version - print version of each module

func WaitForTx

func WaitForTx(tx string) (bool, error)

WaitForTx - wait for a tx on the blockchain to complete. Queries the API every second to see if tx is complete. DEPRECATED

Types

type APIResponse

type APIResponse struct {
	Message  string      `json:"message"`
	Success  bool        `json:"success"`
	Error    string      `json:"error"`
	Response interface{} `json:"response"`
	TxHash   interface{} `json:"txHash"`
	Endpoint string      `json:"endpoint"`
}

APIResponse - standard response from the control daemon api

func ControlDaemonHandler

func ControlDaemonHandler(_res []byte) (APIResponse, error)

ControlDaemonHandler - handler for the API responses

type ErrorResponse

type ErrorResponse struct {
	UserMessage string
	LogError    string
	Path        string
}

ErrorResponse - custom error struct

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error - for the dev/logger

func (*ErrorResponse) Message

func (e *ErrorResponse) Message() string

Message - for the user

Jump to

Keyboard shortcuts

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