node

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 32 Imported by: 3

Documentation

Index

Constants

View Source
const (
	InitBucketSize     = 1 << 24 //16M
	RechargePieceSize  = 1 << 22 //4M
	MaxLostRechargeReq = 16
	ConnectionBufSize  = 1 << 20
)
View Source
const (
	DefaultBaseDir = ".hop"
	WalletFile     = "wallet.json"
	DataBase       = "Receipts"
	LogFile        = "log.hop"
	PidFile        = "pid.hop"
	ConfFile       = "conf.hop"
	WebPort        = 42887
	LMCMD          = "cmd"
)
View Source
const (
	MsgDeliverMicroTx int = iota
	MsgSyncMicroTx
	MsgPingTest
)
View Source
const (
	DBUserMicroTXHead string = "DBUserMicroTx_%s_%s"        //market pool
	DBUserMicroTxKey         = DBUserMicroTXHead + "_%s_%s" //user credit

	DBPoolMicroTxHead          string = "DBPoolMicroTx_%s_%s"        //market pool
	DBPoolMicroTxKey                  = DBPoolMicroTxHead + "_%s_%s" //user credit
	DBPoolMicroTxKeyPatternEnd        = "DBPoolMicroTx_0xffffffffffffffffffff"
)
View Source
const BUFFER_SIZE = 1 << 20

Variables

View Source
var CMDServicePort = "42776"
View Source
var (
	ErrNoPacketBalance = fmt.Errorf("need to recharge for this mienr")
)
View Source
var HopVersion string = "1.1.6"
View Source
var MinerSetting = &SettingConf{EthereumConfig: &com.EthereumConfig{}}
View Source
var PathSetting = &PathConf{}

Functions

func BaseDir

func BaseDir() string

func GetPoolAddr

func GetPoolAddr(miner [32]byte, cfg *config.PlatEthConfig) (addr *common.Address, payeraddr *common.Address, err error)

func InitEthConfig

func InitEthConfig()

func InitMinerNode

func InitMinerNode(auth, port string, networkid int)

func MinerConfFile

func MinerConfFile(bas string) string

func WalletDir

func WalletDir(base string) string

Types

type Bucket

type Bucket struct {
	BID int
	sync.RWMutex
	Token int
	// contains filtered or unexported fields
}

func (*Bucket) ReadCount

func (b *Bucket) ReadCount(no int) error

Tips:: we just count the out put data

func (*Bucket) Recharge

func (b *Bucket) Recharge(no int)

func (*Bucket) WriteCount

func (b *Bucket) WriteCount(no int) error

type BucketManager

type BucketManager interface {
	RechargeBucket(tx *microchain.MicroTX) error
}

type BucketMap

type BucketMap struct {
	sync.RWMutex
	Queue map[common.Address]*Bucket
}

func (*BucketMap) BucketTimer

func (bm *BucketMap) BucketTimer(sig chan struct{})

type MinerConf

type MinerConf struct {
	BAS          string `json:"bas"`
	ECfg         map[int]*com.EthereumConfig
	WebPort      int      `json:"web_port"`
	AccessPubKey []string `json:"access_pub_key"`
}

func (*MinerConf) String

func (mc *MinerConf) String() string

type MinerWallet

type MinerWallet struct {
	account.Wallet
}

func WInst

func WInst() *MinerWallet

type MsgAck

type MsgAck struct {
	Typ  int         `json:"typ"`
	Code int         `json:"code"` //0 success 1 failure
	Msg  string      `json:"msg"`
	Data interface{} `json:"data,omitempty"`
}

func (*MsgAck) String

func (ack *MsgAck) String() string

type MsgReq

type MsgReq struct {
	Typ int                 `json:"typ"`
	SMT *SyncMicroTx        `json:"smt,omitempty"`
	TX  *microchain.MicroTX `json:"tx,omitempty"`
	PT  *PingTest           `json:"pt,omitempty"`
}

func (*MsgReq) String

func (mr *MsgReq) String() string

type Node

type Node struct {
	// contains filtered or unexported fields
}

func SrvNode

func SrvNode() *Node

func (*Node) CheckVersion

func (n *Node) CheckVersion() error

func (*Node) CtrlService

func (n *Node) CtrlService(sig chan struct{})

func (*Node) GetMinerCredit

func (n *Node) GetMinerCredit() *big.Int

func (*Node) GetNodeIns

func (n *Node) GetNodeIns() *NodeIns

func (*Node) GetUserAccount

func (n *Node) GetUserAccount(addr common.Address) *UserAccount

func (*Node) GetUserCount

func (n *Node) GetUserCount() int

func (*Node) GetUsers

func (n *Node) GetUsers() []common.Address

func (*Node) Mining

func (n *Node) Mining(sig chan struct{})

func (*Node) RechargeBucket

func (n *Node) RechargeBucket(r *microchain.MicroTX) error

func (*Node) ReportTx

func (n *Node) ReportTx(sig chan struct{})

func (*Node) ShowUserBucket

func (n *Node) ShowUserBucket(user string) *Bucket

func (*Node) Stop

func (n *Node) Stop()

func (*Node) SyncMicro

func (n *Node) SyncMicro(user common.Address) (tx *microchain.DBMicroTx, find bool, err error)

func (*Node) SyncUa

func (n *Node) SyncUa(user common.Address) (ua *microchain.SyncUA, find bool, err error)

func (*Node) UserManagement

func (n *Node) UserManagement() *UserAccountMgmt

type NodeIns

type NodeIns struct {
	SubAddr   account.ID
	PoolAddr  common.Address
	PayerAddr common.Address
	Database  *leveldb.DB
	UAM       *UserAccountMgmt
}

type PathConf

type PathConf struct {
	WalletPath string
	DBPath     string
	LogPath    string
	PidPath    string
	ConfPath   string

	WebAuthPath       string
	WebAuthTokenPath  string
	WebAuthVerifyPath string

	WebMinerPath    string
	WebMinerDetails string
	WebUserPath     string
	WebUserCount    string
	WebUserInfo     string
}

func (*PathConf) InitPath

func (pc *PathConf) InitPath()

func (*PathConf) String

func (pc *PathConf) String() string

type PingTest

type PingTest struct {
	PayLoad string
}

func (*PingTest) String

func (pt *PingTest) String() string

type ProbeReq

type ProbeReq struct {
	Target        string `json:"Target"`
	MaxPacketSize int    `json:"MaxPacketSize,omitempty"`
}

type SettingConf

type SettingConf struct {
	BAS string
	*com.EthereumConfig
	WebPort      int
	AccessPubKey []string
}

func (*SettingConf) AddAccessAddr

func (cf *SettingConf) AddAccessAddr(addr string) error

func (*SettingConf) GetAccessAddrs

func (ss *SettingConf) GetAccessAddrs() string

func (*SettingConf) GetAccessAddrs2

func (cf *SettingConf) GetAccessAddrs2() []string

func (*SettingConf) GetWebPort

func (cf *SettingConf) GetWebPort() int

func (*SettingConf) RemoveAccessAddr

func (cf *SettingConf) RemoveAccessAddr(addr string) error

func (*SettingConf) Save

func (cf *SettingConf) Save() error

func (*SettingConf) SetWebPort

func (cf *SettingConf) SetWebPort(webPort int)

type SetupData

type SetupData struct {
	IV       network.Salt
	MainAddr common.Address
	SubAddr  account.ID
}

type SetupReq

type SetupReq struct {
	Sig []byte
	*SetupData
}

func (*SetupReq) String

func (sr *SetupReq) String() string

func (*SetupReq) Verify

func (sr *SetupReq) Verify() bool

type SyncMicroTx

type SyncMicroTx struct {
	User common.Address `json:"user"`
}

func (*SyncMicroTx) String

func (sm *SyncMicroTx) String() string

type UserAccount

type UserAccount struct {
	UserAddress    common.Address
	TokenBalance   *big.Int //total recharge
	TrafficBalance *big.Int //recharge to traffic
	TotalTraffic   *big.Int //used in pool

	UptoPoolTraffic *big.Int
	MinerCredit     *big.Int //used in miner

	PoolRefused bool
}

func NewUserAccount

func NewUserAccount() *UserAccount

func (*UserAccount) String

func (ua *UserAccount) String() string

type UserAccountMgmt

type UserAccountMgmt struct {
	// contains filtered or unexported fields
}

func NewUserAccMgmt

func NewUserAccMgmt(db *leveldb.DB, pool common.Address) *UserAccountMgmt

func (*UserAccountMgmt) DBPoolMicroTxKeyDerive

func (uam *UserAccountMgmt) DBPoolMicroTxKeyDerive(key string) (user common.Address, credit *big.Int, err error)

func (*UserAccountMgmt) DBPoolMicroTxKeyGet

func (uam *UserAccountMgmt) DBPoolMicroTxKeyGet(user common.Address, credit *big.Int) string

func (*UserAccountMgmt) DBUserMicroTXKeyDerive

func (uam *UserAccountMgmt) DBUserMicroTXKeyDerive(key string) (user common.Address, credit *big.Int, err error)

func (*UserAccountMgmt) DBUserMicroTXKeyGet

func (uam *UserAccountMgmt) DBUserMicroTXKeyGet(user common.Address, credit *big.Int) string

func (*UserAccountMgmt) GetMinerCredit

func (uam *UserAccountMgmt) GetMinerCredit() *big.Int

func (*UserAccountMgmt) GetUserAccount

func (uam *UserAccountMgmt) GetUserAccount(address common.Address) *UserAccount

func (*UserAccountMgmt) GetUserCount

func (uam *UserAccountMgmt) GetUserCount() int

func (*UserAccountMgmt) GetUsers

func (uam *UserAccountMgmt) GetUsers() (users []common.Address)

func (*UserAccountMgmt) ShowAllReceipt

func (uam *UserAccountMgmt) ShowAllReceipt(user common.Address, report int) string

func (*UserAccountMgmt) ShowAllUser

func (uam *UserAccountMgmt) ShowAllUser() string

func (*UserAccountMgmt) ShowLatestReceipt

func (uam *UserAccountMgmt) ShowLatestReceipt(user common.Address, report int) string

func (*UserAccountMgmt) ShowReceipt

func (uam *UserAccountMgmt) ShowReceipt(user common.Address, credit string, report int) string

func (*UserAccountMgmt) ShowUser

func (uam *UserAccountMgmt) ShowUser(user common.Address) string

Jump to

Keyboard shortcuts

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