Documentation ¶
Overview ¶
Package node provides an engine that combines other components to make up the client.
Index ¶
- 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) GetBlockHashQueue() *queue.Queue
- 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) GetSyncStateInfo() *core.SyncStateInfo
- 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) ProcessBlockHashes()
- func (n *Node) ProdMode() bool
- func (n *Node) PubKey() crypto.PubKey
- 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(protoc *gossip.Gossip)
- 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) SetSyncing(syncing bool)
- 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) UpdateSyncInfo(bi *core.BestBlockInfo)
- func (n *Node) Wait()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) GetBlockHashQueue ¶
GetBlockHashQueue returns the block hash queue
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) GetSyncStateInfo ¶
func (n *Node) GetSyncStateInfo() *core.SyncStateInfo
GetSyncStateInfo generates status and progress information about the current blockchain sync operation
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) ProcessBlockHashes ¶
func (n *Node) ProcessBlockHashes()
ProcessBlockHashes collects hashes and request for their block bodies from the initial broadcaster if the headers.
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) 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
func (*Node) UpdateSyncInfo ¶
func (n *Node) UpdateSyncInfo(bi *core.BestBlockInfo)
UpdateSyncInfo sets a given remote best block info as the best known remote block only when it is better than the local best block. Using this information, it can tell when syncing has stopped and as such, updates the syncing status.