node

package
v0.1.8-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: GPL-3.0 Imports: 40 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 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

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

func (n *Node) Connect(rn core.Engine) error

Connect connects n to

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

func (n *Node) DisableNetwork()

DisableNetwork prevents incoming or outbound connections

func (*Node) GetAddress

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

GetAddress returns the node's address

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

func (n *Node) GetName() string

GetName returns the pet name of the node

func (*Node) GetSyncMode

func (n *Node) GetSyncMode() core.SyncMode

GetSyncMode returns the sync mode

func (*Node) GetTxPool

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

GetTxPool returns the unsigned transaction pool

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

func (n *Node) IsNetworkDisabled() bool

IsNetworkDisabled checks whether networking is disabled

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) 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) 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) 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(mgr *gossip.Manager)

SetGossipProtocol sets the gossip protocol implementation

func (*Node) SetHardcoded

func (n *Node) SetHardcoded(v bool)

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

func (n *Node) SetName(name string)

SetName sets the name of the 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

func (n *Node) SetSyncMode(mode core.SyncMode)

SetSyncMode sets the node's sync mode

func (*Node) SetTxManager

func (n *Node) SetTxManager(tm *TxManager)

SetTxManager sets the transaction manager

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

func (n *Node) Wait()

Wait forces the current thread to wait for the node

type SyncMode

type SyncMode struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SyncMode describes how the state of the node should be synchronized with external nodes.

func NewDefaultSyncMode

func NewDefaultSyncMode(disabled bool) *SyncMode

NewDefaultSyncMode creates a SyncMode object that describes the default sync behaviour

func (*SyncMode) Disable

func (s *SyncMode) Disable()

Disable disables the sync mode

func (*SyncMode) Enable

func (s *SyncMode) Enable()

Enable enables the sync mode

func (*SyncMode) IsDisabled

func (s *SyncMode) IsDisabled() bool

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

func NewTxManager(n *Node) *TxManager

NewTxManager creates a new transaction manager

func (*TxManager) AddTx

func (tm *TxManager) AddTx(tx types.Transaction) error

AddTx adds a transaction to the pool

func (*TxManager) Manage

func (tm *TxManager) Manage()

Manage incoming transaction related events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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