node

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: LGPL-3.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

View Source
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
)
View Source
const ConfigGuideUrl = "Please visit https://github.com/LemoFoundationLtd/lemochain-go#configuration-file for detail"

Variables

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(),
	}
	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",
	}
	// from eth
	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,
	}
)
View Source
var DefaultHTTPVirtualHosts = []string{"localhost"}
View Source
var (
	ErrConfig = errors.New(`file "config.json" format error.` + ConfigGuideUrl)
)

Functions

func DefaultDataDir

func DefaultDataDir() string

func NewApp

func NewApp(usage string) *cli.App

Types

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 (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 ConfigFromFile

type ConfigFromFile struct {
	ChainID   uint64 `json:"chainID"     gencodec:"required"`
	SleepTime uint64 `json:"sleepTime"   gencodec:"required"`
	Timeout   uint64 `json:"timeout"     gencodec:"required"`
}

func (*ConfigFromFile) Check

func (c *ConfigFromFile) Check()

func (ConfigFromFile) MarshalJSON

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

MarshalJSON marshals as JSON.

func (*ConfigFromFile) UnmarshalJSON

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

UnmarshalJSON unmarshals from JSON.

type ConfigFromFileMarshaling

type ConfigFromFileMarshaling struct {
	ChainID   hexutil.Uint64
	SleepTime hexutil.Uint64
	Timeout   hexutil.Uint64
}

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) 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() (*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

func (*PrivateMineAPI) MineStart

func (m *PrivateMineAPI) MineStart()

MineStart

func (*PrivateMineAPI) MineStop

func (m *PrivateMineAPI) MineStop()

MineStop

type PrivateNetAPI

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

PrivateNetAPI

func NewPrivateNetAPI

func NewPrivateNetAPI(node *Node) *PrivateNetAPI

NewPrivateNetAPI

func (*PrivateNetAPI) Connect

func (n *PrivateNetAPI) Connect(node string)

Connect

func (*PrivateNetAPI) Connections

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

Connections

func (*PrivateNetAPI) Disconnect

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

Disconnect

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

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 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) 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

func (*PublicChainAPI) NodeVersion

func (n *PublicChainAPI) NodeVersion() string

NodeVersion

type PublicMineAPI

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

PublicMineAPI

func NewPublicMineAPI

func NewPublicMineAPI(miner *miner.Miner) *PublicMineAPI

NewPublicMineAPI

func (*PublicMineAPI) IsMining

func (m *PublicMineAPI) IsMining() bool

IsMining

func (*PublicMineAPI) MinerAddress

func (m *PublicMineAPI) MinerAddress() string

MinerAddress

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) 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(txpool *chain.TxPool) *PublicTxAPI

NewTxAPI API for send a transaction

func (*PublicTxAPI) PendingTx

func (t *PublicTxAPI) PendingTx(size int) []*types.Transaction

PendingTx

func (*PublicTxAPI) SendTx

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

Send send a transaction

Jump to

Keyboard shortcuts

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