common

package
v0.0.0-...-45a46c7 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 19 Imported by: 4

Documentation

Index

Constants

View Source
const (
	MainNetworkId    = 1
	RopstenNetworkId = 3
	TokenDecimal     = 18
)
View Source
const (
	CurrentVersion        = "0.1.0"
	CmdServicePort        = "42018"
	ConfigDirectory       = ".pool"
	DefaultSystemLogLevel = logging.INFO
	DefaultBaseIP         = "167.179.112.108"
	LMPool                = "pool"
	LMBlockChain          = "blockChain"
	LMCMD                 = "cmd"
	TxReceivePort         = "32020"
	ReceiptSyncPort       = "32021"

	ConfFileName     = "conf.json"
	LogFileName      = "hop.log"
	PIDFileName      = "pid"
	WalletFileName   = "wallet.json"
	DatabaseFileName = "database"
	TimeFormat       = "2006-01-02 15:04:05"
)
View Source
const PipeDialTimeOut = time.Second * 2

Variables

View Source
var (
	LogModules = []string{
		LMPool,
		LMBlockChain,
		LMCMD,
	}
)
View Source
var SysConf = &SysConfig{}
View Source
var SysSetting = &SystemSetting{
	DebugMode:  false,
	LogLevel:   DefaultSystemLogLevel,
	EthApiConf: nil,
}

Functions

func ApplyLogLevel

func ApplyLogLevel()

func ByteToUint

func ByteToUint(buff []byte) uint32

func ConfigBaseDir

func ConfigBaseDir() string

func FileExists

func FileExists(fileName string) (os.FileInfo, bool)

func GetInt

func GetInt(db *leveldb.DB, key string) uint64

func GetJsonObj

func GetJsonObj(db *leveldb.DB, key []byte, v interface{}) error

func GetSavedConn

func GetSavedConn(rAddr string) (net.Conn, error)

func GetSavedTypedConn

func GetSavedTypedConn(network, rAddr string) (net.Conn, error)

func GetString

func GetString(db *leveldb.DB, key string) string

func InitLog

func InitLog(logPath string)

func InitSettings

func InitSettings()

func JoinHostPort

func JoinHostPort(h string, p uint16) string

func MaxInt64

func MaxInt64(a, b *big.Int) *big.Int

func MinInt

func MinInt(a, b int) int

func ReadPassWord2

func ReadPassWord2() (string, error)

func SaveInt

func SaveInt(db *leveldb.DB, key string, val uint64) error

func SaveJsonObj

func SaveJsonObj(db *leveldb.DB, key []byte, v interface{}) error

func SaveString

func SaveString(db *leveldb.DB, key string, val string) error

func SetModuleLogLevel

func SetModuleLogLevel(level logging.Level, module string)

func ShowConfig

func ShowConfig() string

func TouchDir

func TouchDir(dir string) error

func UintToByte

func UintToByte(val uint32) []byte

Types

type ConnSaver

type ConnSaver func(fd uintptr)

type EthereumConfig

type EthereumConfig struct {
	NetworkID   int            `json:"id"`
	EthApiUrl   string         `json:"apiUrl"`
	MicroPaySys common.Address `json:"paymentService"`
	Token       common.Address `json:"token"`
}

func (*EthereumConfig) String

func (ec *EthereumConfig) String() string

type PoolConfig

type PoolConfig struct {
	Version string                  `json:"version"`
	BASIP   string                  `json:"basip"`
	EthConf map[int]*EthereumConfig `json:"ethereum"`
}

type SysConfig

type SysConfig struct {
	WalletPath      string
	ConfPath        string
	LogPath         string
	PidPath         string
	DataServicePath string
}

func (SysConfig) String

func (c SysConfig) String() string

type SystemSetting

type SystemSetting struct {
	PoolVersion string
	BASIP       string
	DebugMode   bool
	LogLevel    logging.Level
	EthApiConf  *EthereumConfig
}

func (*SystemSetting) String

func (ss *SystemSetting) String() string

type Thread

type Thread struct {
	ID      interface{}
	Runner  ThreadRun
	ErrFun  ThreadExit
	StopSig chan struct{}
}

func GetThread

func GetThread(id interface{}) (*Thread, bool)

func NewThread

func NewThread(r ThreadRun, e ThreadExit) *Thread

func NewThreadWithID

func NewThreadWithID(id interface{}, r ThreadRun, e ThreadExit) *Thread

func (*Thread) Start

func (t *Thread) Start()

func (*Thread) Stop

func (t *Thread) Stop()

func (*Thread) String

func (t *Thread) String() string

type ThreadExit

type ThreadExit func(interface{})

type ThreadPool

type ThreadPool struct {
	Pool map[interface{}]*Thread
	// contains filtered or unexported fields
}

type ThreadRun

type ThreadRun func(chan struct{})

Jump to

Keyboard shortcuts

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