Documentation
¶
Index ¶
- Constants
- Variables
- func AvailableTx(tx *types.Transaction) error
- func DefaultDataDir() string
- func NewApp(usage string) *cli.App
- type CandidateInfo
- type CandidateListRes
- type Config
- type NetInfo
- type Node
- func (n *Node) AccountManager() *account.Manager
- func (n *Node) Attach() (*rpc.Client, error)
- func (n *Node) ChainID() uint16
- func (n *Node) DataDir() string
- func (n *Node) Db() protocol.ChainDB
- func (n *Node) Start() error
- func (n *Node) StartMining() error
- func (n *Node) Stop() error
- func (n *Node) Wait()
- type PrivateAccountAPI
- type PrivateMineAPI
- type PrivateNetAPI
- type PublicAccountAPI
- func (a *PublicAccountAPI) GetAccount(LemoAddress string) (types.AccountAccessor, error)
- func (a *PublicAccountAPI) GetAllRewardValue() ([]*params.Reward, error)
- func (a *PublicAccountAPI) GetBalance(LemoAddress string) (string, error)
- func (a *PublicAccountAPI) GetVoteFor(LemoAddress string) (string, error)
- type PublicChainAPI
- func (c *PublicChainAPI) ChainID() uint16
- func (c *PublicChainAPI) CurrentBlock(withBody bool) *types.Block
- func (c *PublicChainAPI) CurrentHeight() uint32
- func (c *PublicChainAPI) GasPriceAdvice() *big.Int
- func (c *PublicChainAPI) Genesis() *types.Block
- func (c *PublicChainAPI) GetBlockByHash(hash string, withBody bool) *types.Block
- func (c *PublicChainAPI) GetBlockByHeight(height uint32, withBody bool) *types.Block
- func (c *PublicChainAPI) GetCandidateList(index, size int) (*CandidateListRes, error)
- func (c *PublicChainAPI) GetCandidateTop30() []*CandidateInfo
- func (c *PublicChainAPI) GetDeputyNodeList() []string
- func (c *PublicChainAPI) LatestStableBlock(withBody bool) *types.Block
- func (c *PublicChainAPI) LatestStableHeight() uint32
- func (n *PublicChainAPI) NodeVersion() string
- type PublicMineAPI
- type PublicNetAPI
- type PublicTxAPI
- func (t *PublicTxAPI) EstimateCreateContractGas(data hexutil.Bytes) (uint64, error)
- func (t *PublicTxAPI) EstimateGas(to *common.Address, txType uint8, data hexutil.Bytes) (string, error)
- func (t *PublicTxAPI) GetTxByHash(hash string) (*store.VTransactionDetail, error)
- func (t *PublicTxAPI) GetTxListByAddress(lemoAddress string, index int, size int) (*TxListRes, error)
- func (t *PublicTxAPI) PendingTx(size int) []*types.Transaction
- func (t *PublicTxAPI) ReadContract(to *common.Address, data hexutil.Bytes) (string, error)
- func (t *PublicTxAPI) SendReimbursedGasTx(senderPrivate, gasPayerPrivate string, to, gasPayer common.Address, ...) (common.Hash, error)
- func (t *PublicTxAPI) SendTx(tx *types.Transaction) (common.Hash, error)
- type TxListRes
Constants ¶
const ( MaxTxToNameLength = 100 MaxTxMessageLength = 1024 )
const ( DefaultHTTPHost = "localhost" // Default host interface for the HTTP RPC server DefaultHTTPPort = 8001 // Default TCP port for the HTTP RPC server DefaultWSHost = "localhost" // Default host interface for the websocket RPC server DefaultWSPort = 8002 // Default TCP port for the websocket RPC server DefaultP2PPort = 60001 DefaultP2pMaxPeerNum = 1000 )
Variables ¶
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") )
var ( DataDirFlag = cli.StringFlag{ Name: common.DataDir, Usage: "Data directory for the databases", Value: DefaultDataDir(), } MaxPeersFlag = cli.IntFlag{ Name: common.MaxPeers, Usage: "Maximum number of network peers", Value: DefaultP2pMaxPeerNum, } ListenPortFlag = cli.IntFlag{ Name: common.ListenPort, Usage: "Network listening port", Value: DefaultP2PPort, } ExtraDataFlag = cli.StringFlag{ Name: common.ExtraData, Usage: "Block extra data set by the miner (default = client version)", } AutoMineFlag = cli.BoolFlag{ Name: common.MiningEnabled, Usage: "Enable mining", } RPCEnabledFlag = cli.BoolFlag{ Name: common.RPCEnabled, Usage: "Enable the HTTP-RPC server", } RPCListenAddrFlag = cli.StringFlag{ Name: common.RPCListenAddr, Usage: "HTTP-RPC server listening interface", Value: DefaultHTTPHost, } 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", } WSListenAddrFlag = cli.StringFlag{ Name: common.WSListenAddr, Usage: "WS-RPC server listening interface", Value: DefaultWSHost, } 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.", } DebugFlag = cli.BoolFlag{ Name: common.Debug, Usage: "Debug for runtime", } JSpathFlag = cli.StringFlag{ Name: common.JSpath, Usage: "JavaScript root path for `loadScript`", Value: ".", } LogLevelFlag = cli.IntFlag{ Name: common.LogLevel, Usage: "Output log level", Value: 4, } )
var DefaultHTTPVirtualHosts = []string{"localhost"}
Functions ¶
func AvailableTx ¶ added in v1.1.0
func AvailableTx(tx *types.Transaction) error
AvailableTx transaction parameter verification
func DefaultDataDir ¶
func DefaultDataDir() string
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 CandidateListRes ¶ added in v1.1.0
type CandidateListRes struct {
CandidateList []*CandidateInfo `json:"candidateList" gencodec:"required"`
Total uint32 `json:"total" gencodec:"required"`
}
func (CandidateListRes) MarshalJSON ¶ added in v1.1.0
func (c CandidateListRes) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*CandidateListRes) UnmarshalJSON ¶ added in v1.1.0
func (c *CandidateListRes) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type Config ¶
type Config struct {
Name string `toml:"-"`
Version string `toml:"-"`
ExtraData []byte `toml:",omitempty"`
DataDir string
P2P p2p.Config
IPCPath string `toml:",omitempty"`
HTTPHost string `toml:",omitempty"`
HTTPPort int `toml:",omitempty"`
HTTPCors []string `toml:",omitempty"`
HTTPVirtualHosts []string `toml:",omitempty"`
WSHost string `toml:",omitempty"`
WSPort int `toml:",omitempty"`
WSOrigins []string `toml:",omitempty"`
WSExposeAll bool `toml:",omitempty"`
}
func (*Config) HTTPEndpoint ¶
func (*Config) NodeKey ¶
func (c *Config) NodeKey() *ecdsa.PrivateKey
func (*Config) StaticNodes ¶
func (*Config) TrustedNodes ¶
func (*Config) WSEndpoint ¶
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 ¶
MarshalJSON marshals as JSON.
func (*NetInfo) UnmarshalJSON ¶
UnmarshalJSON unmarshals from JSON.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) AccountManager ¶
func (*Node) StartMining ¶
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() (*crypto.AccountKey, error)
NewAccount get lemo address api
type PrivateMineAPI ¶
type PrivateMineAPI struct {
// contains filtered or unexported fields
}
PrivateMineAPI
func NewPrivateMinerAPI ¶
func NewPrivateMinerAPI(miner *miner.Miner) *PrivateMineAPI
NewPrivateMinerAPI
type PrivateNetAPI ¶
type PrivateNetAPI struct {
// contains filtered or unexported fields
}
PrivateNetAPI
func (*PrivateNetAPI) Connections ¶
func (n *PrivateNetAPI) Connections() []p2p.PeerConnInfo
Connections
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) GetAllRewardValue ¶ added in v1.1.1
func (a *PublicAccountAPI) GetAllRewardValue() ([]*params.Reward, error)
GetAllRewardValue get the value for each bonus
func (*PublicAccountAPI) GetBalance ¶
func (a *PublicAccountAPI) GetBalance(LemoAddress string) (string, error)
GetBalance get balance in mo
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) CurrentBlock ¶
func (c *PublicChainAPI) CurrentBlock(withBody bool) *types.Block
CurrentBlock get the current latest block
func (*PublicChainAPI) CurrentHeight ¶
func (c *PublicChainAPI) CurrentHeight() uint32
CurrentHeight
func (*PublicChainAPI) GasPriceAdvice ¶
func (c *PublicChainAPI) GasPriceAdvice() *big.Int
GasPriceAdvice get suggest gas price
func (*PublicChainAPI) Genesis ¶
func (c *PublicChainAPI) Genesis() *types.Block
Genesis get the creation block
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) GetCandidateList ¶ added in v1.1.0
func (c *PublicChainAPI) GetCandidateList(index, size int) (*CandidateListRes, error)
GetCandidateNodeList get all candidate node list information and return total candidate node
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() []string
GetDeputyNodeList
func (*PublicChainAPI) LatestStableBlock ¶
func (c *PublicChainAPI) LatestStableBlock(withBody bool) *types.Block
LatestStableBlock get the latest currently agreed blocks
func (*PublicChainAPI) LatestStableHeight ¶
func (c *PublicChainAPI) LatestStableHeight() uint32
LatestStableHeight
type PublicMineAPI ¶
type PublicMineAPI struct {
// contains filtered or unexported fields
}
PublicMineAPI
type PublicNetAPI ¶
type PublicNetAPI struct {
// contains filtered or unexported fields
}
PublicNetAPI
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) EstimateCreateContractGas ¶ added in v1.0.2
func (t *PublicTxAPI) EstimateCreateContractGas(data hexutil.Bytes) (uint64, error)
EstimateContractGas returns an estimate of the amount of gas needed to create a smart contract. todo will delete
func (*PublicTxAPI) EstimateGas ¶ added in v1.0.2
func (t *PublicTxAPI) EstimateGas(to *common.Address, txType uint8, data hexutil.Bytes) (string, error)
EstimateGas returns an estimate of the amount of gas needed to execute the given transaction.
func (*PublicTxAPI) GetTxByHash ¶ added in v1.1.0
func (t *PublicTxAPI) GetTxByHash(hash string) (*store.VTransactionDetail, error)
GetTxByHash pull the specified transaction through a transaction hash
func (*PublicTxAPI) GetTxListByAddress ¶ added in v1.1.0
func (t *PublicTxAPI) GetTxListByAddress(lemoAddress string, index int, size int) (*TxListRes, error)
GetTxListByAddress pull the list of transactions
func (*PublicTxAPI) PendingTx ¶
func (t *PublicTxAPI) PendingTx(size int) []*types.Transaction
PendingTx
func (*PublicTxAPI) ReadContract ¶ added in v1.0.2
ReadContract read variables in a contract includes the return value of a function.
func (*PublicTxAPI) SendReimbursedGasTx ¶ added in v1.1.1
func (t *PublicTxAPI) SendReimbursedGasTx(senderPrivate, gasPayerPrivate string, to, gasPayer common.Address, amount int64, data []byte, txType uint8, toName, message string) (common.Hash, error)
SendReimbursedGasTx gas代付交易 todo 测试使用
func (*PublicTxAPI) SendTx ¶
func (t *PublicTxAPI) SendTx(tx *types.Transaction) (common.Hash, error)
Send send a transaction
type TxListRes ¶ added in v1.1.0
type TxListRes struct {
VTransactions []*store.VTransaction `json:"txList" gencodec:"required"`
Total uint32 `json:"total" gencodec:"required"`
}
func (TxListRes) MarshalJSON ¶ added in v1.1.0
MarshalJSON marshals as JSON.
func (*TxListRes) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON unmarshals from JSON.