node

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: LGPL-3.0 Imports: 38 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultHTTPPort = 8001 // Default TCP port for the HTTP RPC server
	DefaultWSPort   = 8002 // Default TCP port for the websocket RPC server
	DefaultP2PPort  = 60001
)

Variables

View Source
var (
	ErrToName         = errors.New("the length of toName field in transaction is out of max length limit")
	ErrTxMessage      = errors.New("the length of message field in transaction is out of max length limit")
	ErrCreateContract = errors.New("the data of create contract transaction can't be null")
	ErrSpecialTx      = errors.New("the data of special transaction can't be null")
	ErrTxType         = errors.New("the transaction type does not exist")
	ErrAssetId        = errors.New("assetid is incorrect")
	ErrTxExpiration   = errors.New("tx expiration time is out of date")
	ErrNegativeValue  = errors.New("negative value")
	ErrTxChainID      = errors.New("tx chainID is incorrect")
	ErrInputParams    = errors.New("input params incorrect")
	ErrTxTo           = errors.New("transaction to is incorrect")
	ErrNotMiner       = errors.New("the node is not a miner")
)
View Source
var (
	ErrAlreadyRunning    = errors.New("already running")
	ErrOpenFileFailed    = errors.New("open file datadir failed")
	ErrServerStartFailed = errors.New("start p2p server failed")
	ErrRpcStartFailed    = errors.New("start rpc failed")
)
View Source
var (
	DataDirFlag = cli.StringFlag{
		Name:  common.DataDir,
		Usage: "Data directory for the databases",
		Value: DefaultDataDir(),
	}
	ListenPortFlag = cli.IntFlag{
		Name:  common.ListenPort,
		Usage: "Network listening port",
		Value: DefaultP2PPort,
	}
	AutoMineFlag = cli.BoolFlag{
		Name:  common.MiningEnabled,
		Usage: "Enable mining",
	}

	RPCEnabledFlag = cli.BoolFlag{
		Name:  common.RPCEnabled,
		Usage: "Enable the HTTP-RPC server",
	}
	RPCPortFlag = cli.IntFlag{
		Name:  common.RPCPort,
		Usage: "HTTP-RPC server listening port",
		Value: DefaultHTTPPort,
	}
	RPCCORSDomainFlag = cli.StringFlag{
		Name:  common.RPCCORSDomain,
		Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
		Value: "",
	}
	RPCVirtualHostsFlag = cli.StringFlag{
		Name:  common.RPCVirtualHosts,
		Usage: "Comma separated list of virtual hostnames from which to accept requests(server enforced). Accepts '*' wildcard",
		Value: strings.Join(DefaultHTTPVirtualHosts, ","),
	}
	IPCDisabledFlag = cli.BoolFlag{
		Name:  common.IPCDisabled,
		Usage: "Disable the IPC-RPC server",
	}
	IPCPathFlag = cli.StringFlag{
		Name:  common.IPCPath,
		Usage: "Filename for IPC socket/pipe within the datadir",
	}
	WSEnabledFlag = cli.BoolFlag{
		Name:  common.WSEnabled,
		Usage: "Enable the WS-RPC server",
	}
	WSPortFlag = cli.IntFlag{
		Name:  common.WSPort,
		Usage: "WS-RPC server listening port",
		Value: DefaultWSPort,
	}
	WSAllowedOriginsFlag = cli.StringFlag{
		Name:  common.WSAllowedOrigins,
		Usage: "Origins from which to accept websockets request.",
	}
	LogLevelFlag = cli.IntFlag{
		Name:  common.LogLevel,
		Usage: "Output log level",
		Value: 4,
	}
)
View Source
var DefaultHTTPVirtualHosts = []string{"localhost"}

Functions

func DefaultDataDir

func DefaultDataDir() string

func GetChainDataPath added in v1.2.0

func GetChainDataPath(dataDir string) string

func InitLogConfig added in v1.2.0

func InitLogConfig(logFlag int)

InitLogConfig start log server for lemochain-distribution

func NewApp

func NewApp(usage string) *cli.App

Types

type CandidateInfo added in v1.1.0

type CandidateInfo struct {
	CandidateAddress string            `json:"address" gencodec:"required"`
	Votes            string            `json:"votes" gencodec:"required"`
	Profile          map[string]string `json:"profile"  gencodec:"required"`
}

func (CandidateInfo) MarshalJSON added in v1.1.0

func (c CandidateInfo) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*CandidateInfo) UnmarshalJSON added in v1.1.0

func (c *CandidateInfo) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Config

type Config struct {
	Name    string `toml:"-"`
	Version string `toml:"-"`

	DataDir string
	P2P     p2p.Config
	Chain   chain.Config
	Miner   miner.MineConfig

	IPCPath          string   `toml:",omitempty"`
	HTTPPort         int      `toml:",omitempty"`
	HTTPCors         []string `toml:",omitempty"`
	HTTPVirtualHosts []string `toml:",omitempty"`
	WSPort           int      `toml:",omitempty"`
	WSOrigins        []string `toml:",omitempty"`
}

func (*Config) HTTPEndpoint

func (c *Config) HTTPEndpoint() string

func (*Config) IPCEndpoint

func (c *Config) IPCEndpoint() string

IPCEndpoint

func (*Config) NodeKey

func (c *Config) NodeKey() *ecdsa.PrivateKey

func (*Config) NodeName

func (c *Config) NodeName() string

func (*Config) StaticNodes

func (c *Config) StaticNodes() []string

func (*Config) TrustedNodes

func (c *Config) TrustedNodes() []string

func (*Config) WSEndpoint

func (c *Config) WSEndpoint() string

type DeputyNodeInfo added in v1.4.0

type DeputyNodeInfo struct {
	MinerAddress  common.Address `json:"minerAddress"   gencodec:"required"` // candidate account address
	IncomeAddress common.Address `json:"incomeAddress" gencodec:"required"`
	NodeID        []byte         `json:"nodeID"         gencodec:"required"`
	Rank          uint32         `json:"rank"           gencodec:"required"` // start from 0
	Votes         *big.Int       `json:"votes"          gencodec:"required"`
	Host          string         `json:"host"          gencodec:"required"`
	Port          string         `json:"port"          gencodec:"required"`
	DepositAmount string         `json:"depositAmount"  gencodec:"required"` // 质押金额
	Introduction  string         `json:"introduction"  gencodec:"required"`  // 节点介绍
	P2pUri        string         `json:"p2pUri"  gencodec:"required"`        // p2p 连接用的定位符
}

func (DeputyNodeInfo) MarshalJSON added in v1.4.0

func (d DeputyNodeInfo) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*DeputyNodeInfo) UnmarshalJSON added in v1.4.0

func (d *DeputyNodeInfo) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type LemoAccount added in v1.3.0

type LemoAccount struct {
	Private string         `json:"private"`
	Address common.Address `json:"address"`
}

func (LemoAccount) MarshalJSON added in v1.3.0

func (l LemoAccount) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*LemoAccount) UnmarshalJSON added in v1.3.0

func (l *LemoAccount) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type NetInfo

type NetInfo struct {
	Port     uint32 `json:"port"        gencodec:"required"`
	NodeName string `json:"nodeName"    gencodec:"required"`
	Version  string `json:"nodeVersion" gencodec:"required"`
	OS       string `json:"os"          gencodec:"required"`
	Go       string `json:"runtime"     gencodec:"required"`
}

func (NetInfo) MarshalJSON

func (n NetInfo) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*NetInfo) UnmarshalJSON

func (n *NetInfo) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Node

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

func New

func New(flags flag.CmdFlags) *Node

func (*Node) AccountManager

func (n *Node) AccountManager() *account.Manager

func (*Node) Attach

func (n *Node) Attach() (*rpc.Client, error)

func (*Node) ChainID added in v1.0.2

func (n *Node) ChainID() uint16

func (*Node) DataDir

func (n *Node) DataDir() string

func (*Node) Db

func (n *Node) Db() protocol.ChainDB

func (*Node) Start

func (n *Node) Start() error

func (*Node) StartMining

func (n *Node) StartMining() error

func (*Node) Stop

func (n *Node) Stop() error

Stop

func (*Node) Wait

func (n *Node) Wait()

Wait wait for stop

type PrivateAccountAPI

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

Private

func NewPrivateAccountAPI

func NewPrivateAccountAPI(m *account.Manager) *PrivateAccountAPI

NewPrivateAccountAPI

func (*PrivateAccountAPI) NewKeyPair

func (a *PrivateAccountAPI) NewKeyPair() (*LemoAccount, error)

NewAccount get lemo address api

type PrivateChainAPI added in v1.4.0

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

PrivateChainAPI

func NewPrivateChainAPI added in v1.4.0

func NewPrivateChainAPI(chain *chain.BlockChain) *PrivateChainAPI

NewPrivateMinerAPI

func (*PrivateChainAPI) LogForks added in v1.4.0

func (c *PrivateChainAPI) LogForks()

LogForks

type PrivateMineAPI

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

PrivateMineAPI

func NewPrivateMinerAPI

func NewPrivateMinerAPI(miner *miner.Miner) *PrivateMineAPI

NewPrivateMinerAPI

func (*PrivateMineAPI) MineStart

func (m *PrivateMineAPI) MineStart()

MineStart

func (*PrivateMineAPI) MineStop

func (m *PrivateMineAPI) MineStop()

MineStop

func (*PrivateMineAPI) SetLeastGasPrice added in v1.4.0

func (m *PrivateMineAPI) SetLeastGasPrice(price *big.Int)

SetLeastGasPrice

type PrivateNetAPI

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

PrivateNetAPI

func NewPrivateNetAPI

func NewPrivateNetAPI(node *Node) *PrivateNetAPI

NewPrivateNetAPI

func (*PrivateNetAPI) BroadcastConfirm added in v1.4.0

func (n *PrivateNetAPI) BroadcastConfirm(hash string) (bool, error)

BroadcastConfirm

func (*PrivateNetAPI) Connect

func (n *PrivateNetAPI) Connect(node string) error

Connect (node = nodeID@IP:Port)

func (*PrivateNetAPI) Connections

func (n *PrivateNetAPI) Connections() []p2p.PeerConnInfo

Connections

func (*PrivateNetAPI) Disconnect

func (n *PrivateNetAPI) Disconnect(node string) (bool, error)

Disconnect

func (*PrivateNetAPI) FetchConfirm added in v1.4.0

func (n *PrivateNetAPI) FetchConfirm(height uint32) error

FetchConfirm

type PrivateTxAPI added in v1.4.0

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

func NewPrivateTxAPI added in v1.4.0

func NewPrivateTxAPI(node *Node) *PrivateTxAPI

func (*PrivateTxAPI) GetPendingTx added in v1.4.0

func (t *PrivateTxAPI) GetPendingTx(size int) []*types.Transaction

GetPendingTx

type PublicAccountAPI

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

PublicAccountAPI API for access to account information

func NewPublicAccountAPI

func NewPublicAccountAPI(m *account.Manager) *PublicAccountAPI

NewPublicAccountAPI

func (*PublicAccountAPI) GetAccount

func (a *PublicAccountAPI) GetAccount(lemoAddress string) (types.AccountAccessor, error)

GetAccount return the struct of the &AccountData{}

func (*PublicAccountAPI) GetBalance

func (a *PublicAccountAPI) GetBalance(lemoAddress string) (string, error)

GetBalance get balance in mo

func (*PublicAccountAPI) GetEquity added in v1.4.3

func (a *PublicAccountAPI) GetEquity(lemoAddress string, assetId common.Hash) (*types.AssetEquity, error)

GetEquity returns asset equity

func (*PublicAccountAPI) GetVoteFor added in v1.1.0

func (a *PublicAccountAPI) GetVoteFor(lemoAddress string) (string, error)

GetVoteFor

type PublicChainAPI

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

ChainAPI

func NewPublicChainAPI

func NewPublicChainAPI(chain *chain.BlockChain) *PublicChainAPI

NewChainAPI API for access to chain information

func (*PublicChainAPI) ChainID

func (c *PublicChainAPI) ChainID() uint16

ChainID get chain id

func (*PublicChainAPI) CurrentBlock

func (c *PublicChainAPI) CurrentBlock(withBody bool) *types.Block

CurrentBlock get the latest block.

func (*PublicChainAPI) CurrentHeight

func (c *PublicChainAPI) CurrentHeight() uint32

CurrentHeight

func (*PublicChainAPI) Genesis

func (c *PublicChainAPI) Genesis() *types.Block

Genesis get the creation block

func (*PublicChainAPI) GetAllRewardValue added in v1.4.0

func (c *PublicChainAPI) GetAllRewardValue() (params.RewardsMap, error)

GetAllRewardValue get the value for each bonus

func (*PublicChainAPI) GetBlockByHash

func (c *PublicChainAPI) GetBlockByHash(hash string, withBody bool) *types.Block

GetBlockByHash get block information by hash

func (*PublicChainAPI) GetBlockByHeight

func (c *PublicChainAPI) GetBlockByHeight(height uint32, withBody bool) *types.Block

GetBlockByNumber get block information by height

func (*PublicChainAPI) GetCandidateTop30 added in v1.1.0

func (c *PublicChainAPI) GetCandidateTop30() []*CandidateInfo

GetCandidateTop30 get top 30 candidate node

func (*PublicChainAPI) GetDeputyNodeList added in v1.1.0

func (c *PublicChainAPI) GetDeputyNodeList(onlyBlockSigner bool) []*DeputyNodeInfo

GetDeputyNodeList

func (*PublicChainAPI) GetTermReward added in v1.4.0

func (c *PublicChainAPI) GetTermReward(height uint32) (*TermRewardInfo, error)

GetTermReward get term reward info by height

func (*PublicChainAPI) NodeVersion

func (c *PublicChainAPI) NodeVersion() string

NodeVersion

func (*PublicChainAPI) UnstableBlock added in v1.2.0

func (c *PublicChainAPI) UnstableBlock(withBody bool) *types.Block

CurrentBlock get the latest block. It may not be confirmed by enough deputy nodes

func (*PublicChainAPI) UnstableHeight added in v1.2.0

func (c *PublicChainAPI) UnstableHeight() uint32

UnstableHeight

type PublicMineAPI

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

PublicMineAPI

func NewPublicMineAPI

func NewPublicMineAPI(miner *miner.Miner) *PublicMineAPI

NewPublicMineAPI

func (*PublicMineAPI) GetLeastGasPrice added in v1.4.0

func (m *PublicMineAPI) GetLeastGasPrice() string

GetLeastGasPrice

func (*PublicMineAPI) IsMining

func (m *PublicMineAPI) IsMining() bool

IsMining

func (*PublicMineAPI) Miner added in v1.0.1

func (m *PublicMineAPI) Miner() string

Miner

type PublicNetAPI

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

PublicNetAPI

func NewPublicNetAPI

func NewPublicNetAPI(node *Node) *PublicNetAPI

NewPublicNetAPI

func (*PublicNetAPI) Info

func (n *PublicNetAPI) Info() *NetInfo

Info

func (*PublicNetAPI) NodeID added in v1.3.0

func (n *PublicNetAPI) NodeID() string

NodeID

func (*PublicNetAPI) PeersCount

func (n *PublicNetAPI) PeersCount() string

PeersCount return peers number

type PublicTxAPI

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

TXAPI

func NewPublicTxAPI

func NewPublicTxAPI(node *Node) *PublicTxAPI

NewTxAPI API for send a transaction

func (*PublicTxAPI) ReadContract added in v1.0.2

func (t *PublicTxAPI) ReadContract(to *common.Address, data hexutil.Bytes) (string, error)

ReadContract read variables in a contract includes the return value of a function.

func (*PublicTxAPI) SendTx

func (t *PublicTxAPI) SendTx(tx *types.Transaction) (common.Hash, error)

Send send a transaction

type TermRewardInfo added in v1.4.0

type TermRewardInfo struct {
	Term         uint32   `json:"term" gencodec:"required"`
	Value        *big.Int `json:"value" gencodec:"required"`
	RewardHeight uint32   `json:"rewardHeight" gencodec:"required"`
}

func (TermRewardInfo) MarshalJSON added in v1.4.0

func (t TermRewardInfo) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*TermRewardInfo) UnmarshalJSON added in v1.4.0

func (t *TermRewardInfo) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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