Documentation ¶
Index ¶
- Constants
- Variables
- func AddressConvert(address string) (interface{}, error)
- func BytesConverter(source []byte, t string) interface{}
- func DeleteOldFile(fileDirt string) error
- func FileDirectoryInit(filedirt string)
- func FuncParse(funcName string, funcParams []string) (string, []string)
- func GetFileByKey(fileDirt, key string) string
- func GetFileInDirt(fileDirt string) (string, error)
- func GetFuncNameAndParams(funcAndParams string) (string, []string)
- func GetFuncParams(paramString string) []string
- func GetPrivateKey(keyJson []byte) *ecdsa.PrivateKey
- func GetRunningTimePath() string
- func IntValueConvert(value string) (string, error)
- func IsInRange(value string, num uint64) bool
- func IsMatch(param, paramName string) bool
- func IsNameOrAddress(str string) int32
- func IsRoleMatch(role string) bool
- func IsRoleMatchV2(role string) bool
- func IsUrl(url string) bool
- func IsValidRoles(roles string) bool
- func LogInit()
- func ParseFileToBytes(filePath string) ([]byte, error)
- func PrintJson(marshalJson []byte) string
- func PrintRequest(params interface{})
- func TrimSpace(str string) string
- func UintValueConvert(value string) (string, error)
- func WriteFile(fileBytes []byte, filePath string) error
- type KeystoreJson
Constants ¶
const ( CnsIsName int32 = iota CnsIsAddress CnsIsUndefined )
Variables ¶
var ( ErrParamTypeFormat = "incorrect param type: %s, index: %d.\n" ErrReadFileFormat = "read %s file error: %s\n" ErrOpenFileFormat = "open %s file error: %s\n" ErrFindFileFormat = "find file error: %s\n" ErrWriteFileFormat = "write file error: %s" //---------------------------------------------------------------- ErrSendTransacionFormat = "send Transaction through http error: %s" ErrPackFunctionFormat = "packet functions err: %s\n" ErrPackDataFormat = "packet data err: %s\n" ErrParamCheckFormat = "the input <%s> cannot be empty.\n" ErrParamNumCheckFormat = "param check error, required %d inputs, recieved %d.\n" //ErrParamValidFormat = "%s param is not valid: %s\n" ErrParamInValidSyntax = "invalid %s syntax.\n" ErrParamParseFormat = "parse %s param error: %s\n" ErrParseFileFormat = "parse %s file error: %s" ErrUnmarshalBytesFormat = "unmarshal %s bytes error: %s" ErrInputNullFormat = "the %s cannot be empty.\n" ErrRlpEncodeFormat = "rlp encode error: %s" ErrRlpDecodeFormat = "%s rlp decode error: %s" ErrGetFromChainFormat = "get %s from chain error: %s" ErrHttpSendFormat = "send http post error:\n%s" ErrHttpNoResponseFormat = "no response from node: %s" ErrHttpResponseStatusFormat = "http response status: %s" ErrRpcExecuationFormat = "execute %s rpc call error: %s\n" ErrTODO = "something wrong, see more details in %s" PanicUnexpSituation = "unexpected situation in function %s\n" )
var (
ErrFileNull = errors.New("file path cannot be empty")
)
var LogDeg *log.Logger
var LogErr *log.Logger
var Logger *log.Logger
Functions ¶
func AddressConvert ¶
AddressConvert converts hex string format address to byte format address when the input is null, the output address is [0 0 ... 0]
func BytesConverter ¶
BytesConverter converts the bytes to the specific data type it is the same as the BytesConverter in ctool/core/bytes_util.go
func DeleteOldFile ¶
func FileDirectoryInit ¶
func FileDirectoryInit(filedirt string)
FileDirectoryInit creates a new folder if the file directory is not exist
func FuncParse ¶
FuncParse wraps the GetFuncNameAndParams it separates the function method name and the parameters
func GetFileByKey ¶
GetFileByKey search the file in the file directory by the search keywords provided if found, return the file name
func GetFileInDirt ¶
GetFileInDirt get the first file at the file directory
func GetFuncNameAndParams ¶
GetFuncNameAndParams parse the function params from the input string
func GetPrivateKey ¶
func GetPrivateKey(keyJson []byte) *ecdsa.PrivateKey
GetPrivateKey gets the private key by decrypting the keystore file
func GetRunningTimePath ¶
func GetRunningTimePath() string
get the path where the executable is executed
func IsNameOrAddress ¶
TODO refactory IsNameOrAddress Judge whether the input string is an address or a name
func IsRoleMatchV2 ¶
func IsValidRoles ¶
isValidRoles wraps isRoleMatch, it extracts the roles in the array and validates the roles
func ParseFileToBytes ¶
ParseFileToBytes read the file and return the file bytes
func PrintRequest ¶
func PrintRequest(params interface{})
PrintRequest print the request to terminal or log for debugging usage it will limit the printing length if the request is too long