Fabcoin Core
0.16.2
P2P Digital Currency
|
The EthereumHost class. More...
#include <EthereumHost.h>
Public Member Functions | |
EthereumHost (BlockChain const &_ch, OverlayDB const &_db, TransactionQueue &_tq, BlockQueue &_bq, u256 _networkId) | |
Start server, but don't listen. More... | |
virtual | ~EthereumHost () |
Will block on network process events. More... | |
unsigned | protocolVersion () const |
u256 | networkId () const |
void | setNetworkId (u256 _n) |
void | reset () |
void | completeSync () |
Don't sync further - used only in test mode. More... | |
bool | isSyncing () const |
bool | isBanned (p2p::NodeID const &_id) const |
void | noteNewTransactions () |
void | noteNewBlocks () |
void | onBlockImported (BlockHeader const &_info) |
BlockChain const & | chain () const |
OverlayDB const & | db () const |
BlockQueue & | bq () |
BlockQueue const & | bq () const |
SyncStatus | status () const |
h256 | latestBlockSent () |
void | foreachPeer (std::function< bool(std::shared_ptr< EthereumPeer >)> const &_f) const |
Public Member Functions inherited from dev::p2p::HostCapability< EthereumPeer > | |
HostCapability () | |
virtual | ~HostCapability () |
Public Member Functions inherited from dev::p2p::HostCapabilityFace | |
HostCapabilityFace () | |
virtual | ~HostCapabilityFace () |
Host * | host () const |
std::vector< std::pair< std::shared_ptr< SessionFace >, std::shared_ptr< Peer > > > | peerSessions () const |
std::vector< std::pair< std::shared_ptr< SessionFace >, std::shared_ptr< Peer > > > | peerSessions (u256 const &_version) const |
Static Public Member Functions | |
static char const * | stateName (SyncState _s) |
Static Public Member Functions inherited from dev::p2p::HostCapability< EthereumPeer > | |
static std::string | staticName () |
static u256 | staticVersion () |
static unsigned | staticMessageCount () |
Static Public Attributes | |
static unsigned const | c_oldProtocolVersion = 62 |
Protected Member Functions | |
std::shared_ptr< p2p::Capability > | newPeerCapability (std::shared_ptr< p2p::SessionFace > const &_s, unsigned _idOffset, p2p::CapDesc const &_cap, uint16_t _capID) override |
Protected Member Functions inherited from dev::p2p::HostCapability< EthereumPeer > | |
virtual std::string | name () const |
virtual u256 | version () const |
virtual unsigned | messageCount () const |
virtual std::shared_ptr< Capability > | newPeerCapability (std::shared_ptr< SessionFace > const &_s, unsigned _idOffset, CapDesc const &_cap, uint16_t _capID) |
Protected Member Functions inherited from dev::p2p::HostCapabilityFace | |
CapDesc | capDesc () const |
Private Member Functions | |
std::tuple< std::vector< std::shared_ptr< EthereumPeer > >, std::vector< std::shared_ptr< EthereumPeer > >, std::vector< std::shared_ptr< p2p::SessionFace > > > | randomSelection (unsigned _percent=25, std::function< bool(EthereumPeer *)> const &_allow=[](EthereumPeer const *){return true;}) |
virtual void | doWork () override |
Sync with the BlockChain. It might contain one of our mined blocks, we might have new candidates from the network. More... | |
void | maintainTransactions () |
void | maintainBlocks (h256 const &_currentBlock) |
void | onTransactionImported (ImportResult _ir, h256 const &_h, h512 const &_nodeId) |
bool | isInitialised () const |
Check to see if the network peer-state initialisation has happened. More... | |
bool | ensureInitialised () |
Initialises the network peer-state, doing the stuff that needs to be once-only. More... | |
virtual void | onStarting () override |
virtual void | onStopping () override |
Private Member Functions inherited from dev::Worker | |
Worker (std::string const &_name="anon", unsigned _idleWaitMs=30) | |
Worker (Worker &&_m) | |
Move-constructor. More... | |
Worker & | operator= (Worker &&_m) |
Move-assignment. More... | |
virtual | ~Worker () |
void | setName (std::string _n) |
Allows changing worker name if work is stopped. More... | |
void | startWorking () |
Starts worker thread; causes startedWorking() to be called. More... | |
void | stopWorking () |
Stop worker thread; causes call to stopWorking(). More... | |
bool | isWorking () const |
Returns if worker thread is present. More... | |
virtual void | startedWorking () |
Called after thread is started from startWorking(). More... | |
virtual void | workLoop () |
Overrides doWork(); should call shouldStop() often and exit when true. More... | |
bool | shouldStop () const |
virtual void | doneWorking () |
Called when is to be stopped, just prior to thread being joined. More... | |
Private Attributes | |
BlockChain const & | m_chain |
OverlayDB const & | m_db |
References to DB, needed for some of the Ethereum Protocol responses. More... | |
TransactionQueue & | m_tq |
Maintains a list of incoming transactions not yet in a block on the blockchain. More... | |
BlockQueue & | m_bq |
Maintains a list of incoming blocks not yet on the blockchain (to be imported). More... | |
u256 | m_networkId |
h256 | m_latestBlockSent |
h256Hash | m_transactionsSent |
std::unordered_set< p2p::NodeID > | m_banned |
bool | m_newTransactions = false |
bool | m_newBlocks = false |
RecursiveMutex | x_sync |
Mutex | x_transactions |
std::unique_ptr< BlockChainSync > | m_sync |
std::atomic< time_t > | m_lastTick = { 0 } |
std::shared_ptr< EthereumHostDataFace > | m_hostData |
std::shared_ptr< EthereumPeerObserverFace > | m_peerObserver |
Static Private Attributes | |
static char const *const | s_stateNames [static_cast< int >(SyncState::Size)] = {"NotSynced", "Idle", "Waiting", "Blocks", "State", "NewBlocks" } |
The EthereumHost class.
Definition at line 61 of file EthereumHost.h.
EthereumHost::EthereumHost | ( | BlockChain const & | _ch, |
OverlayDB const & | _db, | ||
TransactionQueue & | _tq, | ||
BlockQueue & | _bq, | ||
u256 | _networkId | ||
) |
Start server, but don't listen.
Definition at line 377 of file EthereumHost.cpp.
|
virtual |
Will block on network process events.
Definition at line 395 of file EthereumHost.cpp.
|
inline |
|
inline |
Definition at line 88 of file EthereumHost.h.
|
inline |
void EthereumHost::completeSync | ( | ) |
Don't sync further - used only in test mode.
Definition at line 424 of file EthereumHost.cpp.
|
inline |
Definition at line 86 of file EthereumHost.h.
|
overrideprivatevirtual |
Sync with the BlockChain. It might contain one of our mined blocks, we might have new candidates from the network.
Reimplemented from dev::Worker.
Definition at line 430 of file EthereumHost.cpp.
|
private |
Initialises the network peer-state, doing the stuff that needs to be once-only.
Definition at line 399 of file EthereumHost.cpp.
void EthereumHost::foreachPeer | ( | std::function< bool(std::shared_ptr< EthereumPeer >)> const & | _f | ) | const |
Definition at line 504 of file EthereumHost.cpp.
|
inline |
Definition at line 79 of file EthereumHost.h.
|
inlineprivate |
Check to see if the network peer-state initialisation has happened.
Definition at line 112 of file EthereumHost.h.
bool EthereumHost::isSyncing | ( | ) | const |
|
inline |
Definition at line 90 of file EthereumHost.h.
|
private |
Definition at line 552 of file EthereumHost.cpp.
|
private |
Definition at line 461 of file EthereumHost.cpp.
|
inline |
Definition at line 71 of file EthereumHost.h.
|
overrideprotected |
|
inline |
Definition at line 82 of file EthereumHost.h.
|
inline |
Definition at line 81 of file EthereumHost.h.
|
inline |
Definition at line 83 of file EthereumHost.h.
|
inlineoverrideprivatevirtual |
Reimplemented from dev::p2p::HostCapabilityFace.
Definition at line 117 of file EthereumHost.h.
|
inlineoverrideprivatevirtual |
Reimplemented from dev::p2p::HostCapabilityFace.
Definition at line 118 of file EthereumHost.h.
|
private |
Definition at line 612 of file EthereumHost.cpp.
|
inline |
|
private |
Definition at line 523 of file EthereumHost.cpp.
void EthereumHost::reset | ( | ) |
Definition at line 414 of file EthereumHost.cpp.
|
inline |
Definition at line 72 of file EthereumHost.h.
|
inlinestatic |
Definition at line 91 of file EthereumHost.h.
SyncStatus EthereumHost::status | ( | ) | const |
Definition at line 606 of file EthereumHost.cpp.
|
static |
Definition at line 93 of file EthereumHost.h.
|
private |
Definition at line 130 of file EthereumHost.h.
|
private |
Maintains a list of incoming blocks not yet on the blockchain (to be imported).
Definition at line 123 of file EthereumHost.h.
|
private |
Definition at line 120 of file EthereumHost.h.
|
private |
References to DB, needed for some of the Ethereum Protocol responses.
Definition at line 121 of file EthereumHost.h.
|
private |
Definition at line 140 of file EthereumHost.h.
|
private |
Definition at line 138 of file EthereumHost.h.
|
private |
Definition at line 127 of file EthereumHost.h.
|
private |
Definition at line 125 of file EthereumHost.h.
|
private |
Definition at line 133 of file EthereumHost.h.
|
private |
Definition at line 132 of file EthereumHost.h.
|
private |
Definition at line 141 of file EthereumHost.h.
|
private |
Definition at line 137 of file EthereumHost.h.
|
private |
Maintains a list of incoming transactions not yet in a block on the blockchain.
Definition at line 122 of file EthereumHost.h.
|
private |
Definition at line 128 of file EthereumHost.h.
|
staticprivate |
Definition at line 100 of file EthereumHost.h.
|
mutableprivate |
Definition at line 135 of file EthereumHost.h.
|
mutableprivate |
Definition at line 136 of file EthereumHost.h.