Documentation ¶
Overview ¶
Package node provides an engine that combines other components to make up the client.
Index ¶
- type BlockManager
- type Node
- func NewAlmostEmptyNode() *Node
- func NewNode(config *config.EngineConfig, address string, signatory *d_crypto.Key, ...) (*Node, error)
- func NewNodeWithDB(db elldb.DB, config *config.EngineConfig, address string, ...) (*Node, error)
- func NewRemoteNodeFromMultiAddr(address ma.Multiaddr, localNode *Node) *Node
- func NewTestNodeWithAddress(address ma.Multiaddr) *Node
- func (n *Node) APIs() jsonrpc.APISet
- func (n *Node) AddAddresses(connStrings []string, hardcoded bool) error
- func (n *Node) AddToPeerStore(node core.Engine) core.Engine
- func (n *Node) Connect(rn core.Engine) error
- func (n *Node) Connected() bool
- func (n *Node) CreatedAt() time.Time
- func (n *Node) DB() elldb.DB
- func (n *Node) DevMode() bool
- func (n *Node) DisableNetwork()
- func (n *Node) GetAddress() util.NodeAddr
- func (n *Node) GetBlockchain() types.Blockchain
- func (n *Node) GetCfg() *config.EngineConfig
- func (n *Node) GetEventEmitter() *emitter.Emitter
- func (n *Node) GetHistory() *cache.Cache
- func (n *Node) GetHost() host.Host
- func (n *Node) GetLastSeen() time.Time
- func (n *Node) GetListenAddresses() (addrs []util.NodeAddr)
- func (n *Node) GetName() string
- func (n *Node) GetSyncMode() core.SyncMode
- func (n *Node) GetTxPool() types.TxPool
- func (n *Node) Gossip() core.Gossip
- func (n *Node) HasStopped() bool
- func (n *Node) ID() peer.ID
- func (n *Node) IsHardcodedSeed() bool
- func (n *Node) IsInbound() bool
- func (n *Node) IsNetworkDisabled() bool
- func (n *Node) IsSame(node core.Engine) bool
- func (n *Node) IsSameID(id string) bool
- func (n *Node) NewRemoteNode(address util.NodeAddr) core.Engine
- func (n *Node) OpenDB() error
- func (n *Node) PM() *peermanager.Manager
- func (n *Node) Peerstore() pstore.Peerstore
- func (n *Node) PrivKey() crypto.PrivKey
- func (n *Node) ProdMode() bool
- func (n *Node) PubKey() crypto.PubKey
- func (n *Node) SetBlockManager(bm *BlockManager)
- func (n *Node) SetBlockchain(bChain types.Blockchain)
- func (n *Node) SetCfg(cfg *config.EngineConfig)
- func (n *Node) SetCreatedAt(t time.Time)
- func (n *Node) SetEventEmitter(e *emitter.Emitter)
- func (n *Node) SetGossipManager(m core.Gossip)
- func (n *Node) SetGossipProtocol(mgr *gossip.Manager)
- func (n *Node) SetHardcoded(v bool)
- func (n *Node) SetHost(h host.Host)
- func (n *Node) SetInbound(v bool)
- func (n *Node) SetLastSeen(newTime time.Time)
- func (n *Node) SetLocalNode(node *Node)
- func (n *Node) SetName(name string)
- func (n *Node) SetProtocolHandler(version string, handler inet.StreamHandler)
- func (n *Node) SetSyncMode(mode core.SyncMode)
- func (n *Node) SetTxManager(tm *TxManager)
- func (n *Node) SetTxsPool(txp *txpool.TxPool)
- func (n *Node) ShortID() string
- func (n *Node) Start()
- func (n *Node) Stop()
- func (n *Node) StringID() string
- func (n *Node) TestMode() bool
- func (n *Node) Wait()
- type SyncMode
- type TxManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockManager ¶
type BlockManager struct {
// contains filtered or unexported fields
}
BlockManager is responsible for handling incoming, mined or processed blocks in a concurrency safe way.
func NewBlockManager ¶
func NewBlockManager(node *Node) *BlockManager
NewBlockManager creates a new BlockManager
func (*BlockManager) GetSyncStat ¶
func (bm *BlockManager) GetSyncStat() *core.SyncStateInfo
GetSyncStat returns progress information about the current blockchain synchronization session.
func (*BlockManager) IsSyncing ¶
func (bm *BlockManager) IsSyncing() bool
IsSyncing checks whether block syncing is active.
func (*BlockManager) Manage ¶
func (bm *BlockManager) Manage()
Manage handles all incoming block related events.
func (*BlockManager) SetMiner ¶
func (bm *BlockManager) SetMiner(m *miner.Miner)
SetMiner sets a reference of the CPU miner
type Node ¶
type Node struct { IP net.IP // node ip Name string // Random name for this node // contains filtered or unexported fields }
Node represents a network node
func NewAlmostEmptyNode ¶
func NewAlmostEmptyNode() *Node
NewAlmostEmptyNode returns a node with almost all its field uninitialized.
func NewNode ¶
func NewNode(config *config.EngineConfig, address string, signatory *d_crypto.Key, log logger.Logger) (*Node, error)
NewNode creates a Node instance
func NewNodeWithDB ¶
func NewNodeWithDB(db elldb.DB, config *config.EngineConfig, address string, signatory *d_crypto.Key, log logger.Logger) (*Node, error)
NewNodeWithDB is like NewNode but it accepts a db instance
func NewRemoteNodeFromMultiAddr ¶
NewRemoteNodeFromMultiAddr is like NewRemoteNode excepts it accepts a Multiaddr
func NewTestNodeWithAddress ¶
NewTestNodeWithAddress returns a node with with the given address set
func (*Node) AddAddresses ¶
AddAddresses adds addresses which the engine can establish connections to.
func (*Node) AddToPeerStore ¶
AddToPeerStore adds the ID of the engine to the peerstore
func (*Node) Connected ¶
Connected checks whether the node is connected to the local node. Returns false if node is the local node.
func (*Node) DisableNetwork ¶
func (n *Node) DisableNetwork()
DisableNetwork prevents incoming or outbound connections
func (*Node) GetAddress ¶
GetAddress returns the node's address
func (*Node) GetBlockchain ¶
func (n *Node) GetBlockchain() types.Blockchain
GetBlockchain returns the blockchain manager
func (*Node) GetEventEmitter ¶
GetEventEmitter gets the event emitter
func (*Node) GetHistory ¶
GetHistory return a cache for holding arbitrary objects we want to keep track of
func (*Node) GetLastSeen ¶
GetLastSeen gets the nodes timestamp
func (*Node) GetListenAddresses ¶
GetListenAddresses gets the address at which the node listens
func (*Node) GetSyncMode ¶
GetSyncMode returns the sync mode
func (*Node) HasStopped ¶
HasStopped checks whether the node has stopped
func (*Node) IsHardcodedSeed ¶
IsHardcodedSeed checks whether the node is an hardcoded seed node
func (*Node) IsNetworkDisabled ¶
IsNetworkDisabled checks whether networking is disabled
func (*Node) NewRemoteNode ¶
NewRemoteNode creates a Node that represents a remote node
func (*Node) OpenDB ¶
OpenDB opens the database. In dev mode, create a namespace and open database file prefixed with the namespace.
func (*Node) SetBlockManager ¶
func (n *Node) SetBlockManager(bm *BlockManager)
SetBlockManager sets the block manager
func (*Node) SetBlockchain ¶
func (n *Node) SetBlockchain(bChain types.Blockchain)
SetBlockchain sets the blockchain
func (*Node) SetCreatedAt ¶
SetCreatedAt sets the time the node was created
func (*Node) SetEventEmitter ¶
SetEventEmitter set the event bus used to broadcast events across the engine
func (*Node) SetGossipManager ¶
SetGossipManager sets the gossip manager
func (*Node) SetGossipProtocol ¶
SetGossipProtocol sets the gossip protocol implementation
func (*Node) SetHardcoded ¶
SetHardcoded sets the hardcoded seed state of the engine.
func (*Node) SetInbound ¶
SetInbound set the connection as inbound or not
func (*Node) SetLastSeen ¶
SetLastSeen sets the timestamp value
func (*Node) SetLocalNode ¶
SetLocalNode sets the node as the local node to n which makes n the "remote" node
func (*Node) SetProtocolHandler ¶
func (n *Node) SetProtocolHandler(version string, handler inet.StreamHandler)
SetProtocolHandler sets the protocol handler for a specific protocol
func (*Node) SetSyncMode ¶
SetSyncMode sets the node's sync mode
func (*Node) SetTxManager ¶
SetTxManager sets the transaction manager
func (*Node) SetTxsPool ¶
SetTxsPool sets the transaction pool
type SyncMode ¶
SyncMode describes how the state of the node should be synchronized with external nodes.
func NewDefaultSyncMode ¶
NewDefaultSyncMode creates a SyncMode object that describes the default sync behaviour
func (*SyncMode) IsDisabled ¶
IsDisabled checks whether the syncing has been disabled.
type TxManager ¶
type TxManager struct {
// contains filtered or unexported fields
}
TxManager is responsible for processing incoming transactions, constructing new transactions and more.
func NewTxManager ¶
NewTxManager creates a new transaction manager