utils

package
v0.0.0-...-d704c37 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TDPID_FILE = "./.tendermint_pid"
	RDPID_FILE = "./.redimint_pid"
	DBPID_FILE = "./.redis_pid"
)
View Source
const (
	DbTxLogFilePath = "../log/db_transactions"
	AppLogFilePath  = "../log/application.log"
)

Variables

View Source
var NodeKey *p2p.NodeKey
View Source
var ValidatorKey *privval.FilePVKey

Functions

func AppendToDBLogFile

func AppendToDBLogFile(lines []string) error

command | addr | sign | seq | height | time

func ByteToHex

func ByteToHex(b []byte) string

func CopyFile

func CopyFile(src, dst string) error

existing file will be overwritten

func CreateDir

func CreateDir(path string)

func DeleteFile

func DeleteFile(path string)

func EncodeMD5

func EncodeMD5(value string) string

func Exists

func Exists(path string) bool

func GenerateToken

func GenerateToken(address string, mode string, username string, password string) (string, error)

GenerateToken generate tokens used for auth

func GetNodeID

func GetNodeID() string

#################### Node key ####################

func HexToByte

func HexToByte(s string) []byte

func InitConfig

func InitConfig()

func InitFiles

func InitFiles()

func InitJWTMethod

func InitJWTMethod()

func InitKey

func InitKey()

func InitNodeKey

func InitNodeKey()

func InitValidatorKey

func InitValidatorKey()

func JsonToStruct

func JsonToStruct(j []byte, s interface{})

func NodeSign

func NodeSign(msg []byte) []byte

func NodeStringSign

func NodeStringSign(msg []byte) string

func ReadAll

func ReadAll(path string) string

func ReadPIDFile

func ReadPIDFile(path string) string

func ReadTxFromDBLogFile

func ReadTxFromDBLogFile(beginHeight int, endHeight int) ([]string, error)

command | addr | sign | seq | height | time

func SavePID

func SavePID(pid int, pidFile string)

func SignToHex

func SignToHex(b []byte) string

func StartRedimintDaemon

func StartRedimintDaemon()

func StartRedisDaemon

func StartRedisDaemon()

func StartTendermintDaemon

func StartTendermintDaemon()

func StopPID

func StopPID(pid string)

func StructToJson

func StructToJson(v interface{}) []byte

func ValidatorSign

func ValidatorSign(msg []byte) []byte

#################### Validator key ####################

func ValidatorStringSign

func ValidatorStringSign(msg []byte) string

Types

type AppConfig

type AppConfig struct {
	Name          string `yaml:"name"`
	DbPassword    string `yaml:"db_password"`
	AdminUser     string `yaml:"admin_user"`
	AdminPassword string `yaml:"admin_passowrd"`
	Plugin        string `yaml:"plugin" default:"default"`
}

type Claims

type Claims struct {
	Address  string `json:"address"`
	Mode     string `json:"mode"`
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

ParseToken parsing token

type Configuration

type Configuration struct {
	App        AppConfig        `yaml:"app-config"`
	Rpc        RpcConfig        `yaml:"rpc-config"`
	IPFS       IPFSConfig       `yaml:"ipfs-config"`
	Redis      RedisConfig      `yaml:"redis-config"`
	Tendermint TendermintConfig `yaml:"tendermint-config"`
	HttpServer HttpServerConfig `yaml:"http-server-config"`
}
var Config Configuration

type HttpServerConfig

type HttpServerConfig struct {
	RunMode      string        `yaml:"run_mode"`
	Port         int           `yaml:"port"`
	ReadTimeout  time.Duration `yaml:"read_timeout"`
	WriteTimeout time.Duration `yaml:"write_timeout"`
}

type IPFSConfig

type IPFSConfig struct {
	Url string `yaml:"url"`
}

type NodeKeySignMethod

type NodeKeySignMethod struct {
}

func (NodeKeySignMethod) Alg

func (n NodeKeySignMethod) Alg() string

func (NodeKeySignMethod) Sign

func (n NodeKeySignMethod) Sign(signingString string, key interface{}) (string, error)

func (NodeKeySignMethod) Verify

func (n NodeKeySignMethod) Verify(signingString, signature string, key interface{}) error

type Percent

type Percent uint32

percent

func (Percent) Float

func (p Percent) Float() float64

func (Percent) String

func (p Percent) String() string

type RedisConfig

type RedisConfig struct {
	Url      string `yaml:"url"`
	Db       int    `yaml:"db"`
	Password string `yaml:"password"`
	RDBPath  string `yaml:"rdb_path"`
}

type RpcConfig

type RpcConfig struct {
	Port int `yaml:"port"`
}

type TendermintConfig

type TendermintConfig struct {
	Url string `yaml:"url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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