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) AddTransaction(tx types.Transaction) error
- func (n *Node) Connected() bool
- func (n *Node) CountIntros() int
- func (n *Node) CreatedAt() time.Time
- func (n *Node) DB() elldb.DB
- func (n *Node) DevMode() bool
- 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) GetIntros() *cache.Cache
- func (n *Node) GetLastSeen() time.Time
- func (n *Node) GetListenAddresses() (addrs []util.NodeAddr)
- func (n *Node) GetTxPool() types.TxPool
- func (n *Node) GetTxRelayQueue() *txpool.TxContainer
- 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) 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 core.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.GossipManager)
- func (n *Node) SetHardcodedState(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) SetProtocolHandler(version string, handler inet.StreamHandler)
- 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()
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) GetSyncStateInfo ¶
func (bm *BlockManager) GetSyncStateInfo() *core.SyncStateInfo
GetSyncStateInfo returns progress information about the current blockchain synchronization session.
func (*BlockManager) Handle ¶
func (bm *BlockManager) Handle()
Handle handles all incoming block related events.
func (*BlockManager) IsSyncing ¶
func (bm *BlockManager) IsSyncing() bool
IsSyncing checks whether block syncing is active.
func (*BlockManager) SetMiner ¶
func (bm *BlockManager) SetMiner(m *miner.Miner)
SetMiner sets a reference of the CPU miner
func (*BlockManager) SetTxPool ¶
func (bm *BlockManager) SetTxPool(tp types.TxPool)
SetTxPool sets a reference of the transaction pool
type Node ¶
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) AddTransaction ¶
func (n *Node) AddTransaction(tx types.Transaction) error
AddTransaction validates and adds a transaction to the transaction pool.
func (*Node) Connected ¶
Connected checks whether the node is connected to the local node. Returns false if node is the local node.
func (*Node) CountIntros ¶
CountIntros counts the number of intros received
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) GetTxRelayQueue ¶
func (n *Node) GetTxRelayQueue() *txpool.TxContainer
GetTxRelayQueue returns the transaction relay queue
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) 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 core.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 ¶
func (n *Node) SetGossipProtocol(mgr *gossip.GossipManager)
SetGossipProtocol sets the gossip protocol implementation
func (*Node) SetHardcodedState ¶
SetHardcodedState 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) SetTxsPool ¶
SetTxsPool sets the transaction pool