node

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2018 License: GPL-3.0 Imports: 32 Imported by: 1

Documentation

Overview

Package node provides an engine that combines other components to make up the client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	IP net.IP // node ip
	// 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

func NewRemoteNodeFromMultiAddr(address ma.Multiaddr, localNode *Node) *Node

NewRemoteNodeFromMultiAddr is like NewRemoteNode excepts it accepts a Multiaddr

func NewTestNodeWithAddress

func NewTestNodeWithAddress(address ma.Multiaddr) *Node

NewTestNodeWithAddress returns a node with with the given address set

func (*Node) APIs

func (n *Node) APIs() jsonrpc.APISet

APIs returns all API handlers

func (*Node) AddAddresses

func (n *Node) AddAddresses(connStrings []string, hardcoded bool) error

AddAddresses adds addresses which the engine can establish connections to.

func (*Node) AddToPeerStore

func (n *Node) AddToPeerStore(node core.Engine) core.Engine

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

func (n *Node) Connected() bool

Connected checks whether the node is connected to the local node. Returns false if node is the local node.

func (*Node) CountIntros

func (n *Node) CountIntros() int

CountIntros counts the number of intros received

func (*Node) CreatedAt

func (n *Node) CreatedAt() time.Time

CreatedAt returns the node's time of creation

func (*Node) DB

func (n *Node) DB() elldb.DB

DB returns the database instance

func (*Node) DevMode

func (n *Node) DevMode() bool

DevMode checks whether the node is in dev mode

func (*Node) GetAddress

func (n *Node) GetAddress() util.NodeAddr

GetAddress returns the node's address

func (*Node) GetBlockHashQueue

func (n *Node) GetBlockHashQueue() *queue.Queue

GetBlockHashQueue returns the block hash queue

func (*Node) GetBlockchain

func (n *Node) GetBlockchain() types.Blockchain

GetBlockchain returns the blockchain manager

func (*Node) GetCfg

func (n *Node) GetCfg() *config.EngineConfig

GetCfg returns the config

func (*Node) GetEventEmitter

func (n *Node) GetEventEmitter() *emitter.Emitter

GetEventEmitter gets the event emitter

func (*Node) GetHistory

func (n *Node) GetHistory() *cache.Cache

GetHistory return a cache for holding arbitrary objects we want to keep track of

func (*Node) GetHost

func (n *Node) GetHost() host.Host

GetHost returns the node's host

func (*Node) GetIntros

func (n *Node) GetIntros() *cache.Cache

GetIntros returns the cache containing received intros

func (*Node) GetLastSeen

func (n *Node) GetLastSeen() time.Time

GetLastSeen gets the nodes timestamp

func (*Node) GetListenAddresses

func (n *Node) GetListenAddresses() (addrs []util.NodeAddr)

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

func (n *Node) GetTxPool() types.TxPool

GetTxPool returns the unsigned transaction pool

func (*Node) GetTxRelayQueue

func (n *Node) GetTxRelayQueue() *txpool.TxContainer

GetTxRelayQueue returns the transaction relay queue

func (*Node) Gossip

func (n *Node) Gossip() core.Gossip

Gossip returns the set protocol

func (*Node) HasStopped

func (n *Node) HasStopped() bool

HasStopped checks whether the node has stopped

func (*Node) ID

func (n *Node) ID() peer.ID

ID returns the peer id of the host

func (*Node) IsHardcodedSeed

func (n *Node) IsHardcodedSeed() bool

IsHardcodedSeed checks whether the node is an hardcoded seed node

func (*Node) IsInbound

func (n *Node) IsInbound() bool

IsInbound checks whether the connection is inbound

func (*Node) IsSame

func (n *Node) IsSame(node core.Engine) bool

IsSame checks if p is the same as node

func (*Node) IsSameID

func (n *Node) IsSameID(id string) bool

IsSameID is like IsSame except it accepts string

func (*Node) NewRemoteNode

func (n *Node) NewRemoteNode(address util.NodeAddr) core.Engine

NewRemoteNode creates a Node that represents a remote node

func (*Node) OpenDB

func (n *Node) OpenDB() error

OpenDB opens the database. In dev mode, create a namespace and open database file prefixed with the namespace.

func (*Node) PM

func (n *Node) PM() *peermanager.Manager

PM returns the peer manager

func (*Node) Peerstore

func (n *Node) Peerstore() pstore.Peerstore

Peerstore returns the Peerstore of the node

func (*Node) PrivKey

func (n *Node) PrivKey() crypto.PrivKey

PrivKey returns the node's private key

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

func (n *Node) ProdMode() bool

ProdMode checks whether the node is in production mode

func (*Node) PubKey

func (n *Node) PubKey() crypto.PubKey

PubKey returns the node's public key

func (*Node) SetBlockchain

func (n *Node) SetBlockchain(bchain types.Blockchain)

SetBlockchain sets the blockchain

func (*Node) SetCfg

func (n *Node) SetCfg(cfg *config.EngineConfig)

SetCfg sets the node's config

func (*Node) SetCreatedAt

func (n *Node) SetCreatedAt(t time.Time)

SetCreatedAt sets the time the node was created

func (*Node) SetEventEmitter

func (n *Node) SetEventEmitter(e *emitter.Emitter)

SetEventEmitter set the event bus used to broadcast events across the engine

func (*Node) SetGossipManager

func (n *Node) SetGossipManager(m core.Gossip)

SetGossipManager sets the gossip manager

func (*Node) SetGossipProtocol

func (n *Node) SetGossipProtocol(protoc *gossip.Gossip)

SetGossipProtocol sets the gossip protocol implementation

func (*Node) SetHardcodedState

func (n *Node) SetHardcodedState(v bool)

SetHardcodedState sets the hardcoded seed state of the engine.

func (*Node) SetHost

func (n *Node) SetHost(h host.Host)

SetHost sets the host

func (*Node) SetInbound

func (n *Node) SetInbound(v bool)

SetInbound set the connection as inbound or not

func (*Node) SetLastSeen

func (n *Node) SetLastSeen(newTime time.Time)

SetLastSeen sets the timestamp value

func (*Node) SetLocalNode

func (n *Node) SetLocalNode(node *Node)

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

func (n *Node) SetSyncing(syncing bool)

SetSyncing sets the sync status

func (*Node) SetTxsPool

func (n *Node) SetTxsPool(txp *txpool.TxPool)

SetTxsPool sets the transaction pool

func (*Node) ShortID

func (n *Node) ShortID() string

ShortID is like IDPretty but shorter

func (*Node) Start

func (n *Node) Start()

Start starts the node.

func (*Node) Stop

func (n *Node) Stop()

Stop stops the node and releases any held resources.

func (*Node) StringID

func (n *Node) StringID() string

StringID is like ID() but it returns string

func (*Node) TestMode

func (n *Node) TestMode() bool

TestMode checks whether the node is in test mode

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.

func (*Node) Wait

func (n *Node) Wait()

Wait forces the current thread to wait for the node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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