Ethereum  PoC-8
The C++ Implementation of Ethereum
dev::WebThreeDirect Class Reference

Main API hub for interfacing with Web 3 components. This doesn't do any local multiplexing, so you can only have one running on any given machine for the provided DB path. More...

#include <WebThree.h>

Inheritance diagram for dev::WebThreeDirect:
dev::NetworkFace

Public Member Functions

 WebThreeDirect (std::string const &_clientVersion, boost::filesystem::path const &_dbPath, boost::filesystem::path const &_snapshotPath, eth::ChainParams const &_params, WithExisting _we=WithExisting::Trust, p2p::NetworkConfig const &_n=p2p::NetworkConfig{}, bytesConstRef _network=bytesConstRef(), bool _testing=false)
 
 ~WebThreeDirect () override
 Destructor. More...
 
eth::Clientethereum () const
 
std::string const & clientVersion () const
 
std::vector< p2p::PeerSessionInfo > peers () override
 Get information on the current peer set. More...
 
size_t peerCount () const override
 Same as peers().size(), but more efficient. More...
 
virtual void addPeer (p2p::NodeSpec const &_node, p2p::PeerType _t) override
 Generalised peer addition. More...
 
virtual void addNode (p2p::NodeID const &_node, bi::tcp::endpoint const &_hostEndpoint) override
 Add node to connect to. More...
 
void addNode (p2p::NodeID const &_node, std::string const &_hostString)
 Add node to connect to. More...
 
void addNode (bi::tcp::endpoint const &_endpoint)
 Add node to connect to. More...
 
void addNode (std::string const &_hostString)
 Add node to connect to. More...
 
void requirePeer (p2p::NodeID const &_node, bi::tcp::endpoint const &_endpoint) override
 Require connection to peer. More...
 
void requirePeer (p2p::NodeID const &_node, std::string const &_hostString)
 Require connection to peer. More...
 
dev::bytes saveNetwork () override
 Save peers. More...
 
void setIdealPeerCount (size_t _n) override
 Sets the ideal number of peers. More...
 
void setPeerStretch (size_t _n)
 Experimental. Sets ceiling for incoming connections to multiple of ideal peer count. More...
 
p2p::NodeInfo nodeInfo () const override
 Get information concerning this node. More...
 
u256 networkId () const override
 Get network id. More...
 
std::string enode () const override
 Get enode string. More...
 
void startNetwork () override
 Start the network subsystem. More...
 
void stopNetwork () override
 Stop the network subsystem. More...
 
bool isNetworkStarted () const override
 Is network working? there may not be any peers yet. More...
 
- Public Member Functions inherited from dev::NetworkFace
virtual ~NetworkFace ()=default
 

Static Public Member Functions

static std::string composeClientVersion (std::string const &_client)
 

Detailed Description

Main API hub for interfacing with Web 3 components. This doesn't do any local multiplexing, so you can only have one running on any given machine for the provided DB path.

Keeps a libp2p Host going (administering the work thread with m_workNet).

Encapsulates a bunch of P2P protocols (interfaces), each using the same underlying libp2p Host.

Provides a baseline for the multiplexed multi-protocol session class, WebThree.

Definition at line 108 of file WebThree.h.

Constructor & Destructor Documentation

◆ WebThreeDirect()

WebThreeDirect::WebThreeDirect ( std::string const &  _clientVersion,
boost::filesystem::path const &  _dbPath,
boost::filesystem::path const &  _snapshotPath,
eth::ChainParams const &  _params,
WithExisting  _we = WithExisting::Trust,
p2p::NetworkConfig const &  _n = p2p::NetworkConfig{},
bytesConstRef  _network = bytesConstRef(),
bool  _testing = false 
)

Constructor for private instance. If there is already another process on the machine using _dbPath, then this will throw an exception. ethereum() may be safely static_cast()ed to a eth::Client*.

Definition at line 37 of file WebThree.cpp.

◆ ~WebThreeDirect()

WebThreeDirect::~WebThreeDirect ( )
override

Destructor.

Definition at line 59 of file WebThree.cpp.

Member Function Documentation

◆ addNode() [1/4]

void dev::WebThreeDirect::addNode ( bi::tcp::endpoint const &  _endpoint)
inline

Add node to connect to.

Definition at line 153 of file WebThree.h.

◆ addNode() [2/4]

void WebThreeDirect::addNode ( p2p::NodeID const &  _node,
bi::tcp::endpoint const &  _hostEndpoint 
)
overridevirtual

Add node to connect to.

Implements dev::NetworkFace.

Definition at line 106 of file WebThree.cpp.

◆ addNode() [3/4]

void dev::WebThreeDirect::addNode ( p2p::NodeID const &  _node,
std::string const &  _hostString 
)
inline

Add node to connect to.

Definition at line 150 of file WebThree.h.

◆ addNode() [4/4]

void dev::WebThreeDirect::addNode ( std::string const &  _hostString)
inline

Add node to connect to.

Definition at line 156 of file WebThree.h.

◆ addPeer()

void WebThreeDirect::addPeer ( p2p::NodeSpec const &  _node,
p2p::PeerType  _t 
)
overridevirtual

Generalised peer addition.

Implements dev::NetworkFace.

Definition at line 116 of file WebThree.cpp.

◆ clientVersion()

std::string const& dev::WebThreeDirect::clientVersion ( ) const
inline

Definition at line 133 of file WebThree.h.

◆ composeClientVersion()

std::string WebThreeDirect::composeClientVersion ( std::string const &  _client)
static

Definition at line 74 of file WebThree.cpp.

◆ enode()

std::string dev::WebThreeDirect::enode ( ) const
inlineoverridevirtual

Get enode string.

Implements dev::NetworkFace.

Definition at line 177 of file WebThree.h.

◆ ethereum()

eth::Client* dev::WebThreeDirect::ethereum ( ) const
inline

Definition at line 123 of file WebThree.h.

◆ isNetworkStarted()

bool dev::WebThreeDirect::isNetworkStarted ( ) const
inlineoverridevirtual

Is network working? there may not be any peers yet.

Implements dev::NetworkFace.

Definition at line 186 of file WebThree.h.

◆ networkId()

u256 dev::WebThreeDirect::networkId ( ) const
inlineoverridevirtual

Get network id.

Implements dev::NetworkFace.

Definition at line 175 of file WebThree.h.

◆ nodeInfo()

p2p::NodeInfo dev::WebThreeDirect::nodeInfo ( ) const
inlineoverridevirtual

Get information concerning this node.

Implements dev::NetworkFace.

Definition at line 173 of file WebThree.h.

◆ peerCount()

size_t WebThreeDirect::peerCount ( ) const
overridevirtual

Same as peers().size(), but more efficient.

Implements dev::NetworkFace.

Definition at line 86 of file WebThree.cpp.

◆ peers()

std::vector< PeerSessionInfo > WebThreeDirect::peers ( )
overridevirtual

Get information on the current peer set.

Implements dev::NetworkFace.

Definition at line 81 of file WebThree.cpp.

◆ requirePeer() [1/2]

void WebThreeDirect::requirePeer ( p2p::NodeID const &  _node,
bi::tcp::endpoint const &  _endpoint 
)
overridevirtual

Require connection to peer.

Implements dev::NetworkFace.

Definition at line 111 of file WebThree.cpp.

◆ requirePeer() [2/2]

void dev::WebThreeDirect::requirePeer ( p2p::NodeID const &  _node,
std::string const &  _hostString 
)
inline

Require connection to peer.

Definition at line 162 of file WebThree.h.

◆ saveNetwork()

bytes WebThreeDirect::saveNetwork ( )
overridevirtual

Save peers.

Implements dev::NetworkFace.

Definition at line 101 of file WebThree.cpp.

◆ setIdealPeerCount()

void WebThreeDirect::setIdealPeerCount ( size_t  _n)
overridevirtual

Sets the ideal number of peers.

Implements dev::NetworkFace.

Definition at line 91 of file WebThree.cpp.

◆ setPeerStretch()

void WebThreeDirect::setPeerStretch ( size_t  _n)

Experimental. Sets ceiling for incoming connections to multiple of ideal peer count.

Definition at line 96 of file WebThree.cpp.

◆ startNetwork()

void dev::WebThreeDirect::startNetwork ( )
inlineoverridevirtual

Start the network subsystem.

Implements dev::NetworkFace.

Definition at line 180 of file WebThree.h.

◆ stopNetwork()

void dev::WebThreeDirect::stopNetwork ( )
inlineoverridevirtual

Stop the network subsystem.

Implements dev::NetworkFace.

Definition at line 183 of file WebThree.h.


The documentation for this class was generated from the following files: