Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
dev::WebThreeDirect Class Reference

Main API hub for interfacing with Web 3 components. More...

#include <WebThree.h>

Inheritance diagram for dev::WebThreeDirect:
[legend]
Collaboration diagram for dev::WebThreeDirect:
[legend]

Public Member Functions

 WebThreeDirect (std::string const &_clientVersion, std::string const &_dbPath, eth::ChainParams const &_params, WithExisting _we=WithExisting::Trust, std::set< std::string > const &_interfaces={"eth","shh","bzz"}, p2p::NetworkPreferences const &_n=p2p::NetworkPreferences(), bytesConstRef _network=bytesConstRef(), bool _testing=false)
 Constructor for private instance. More...
 
 ~WebThreeDirect ()
 Destructor. More...
 
eth::Clientethereum () const
 
std::shared_ptr< shh::WhisperHostwhisper () const
 
std::string const & clientVersion () const
 
std::vector< p2p::PeerSessionInfopeers () 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...
 
bool haveNetwork () const override
 
p2p::NetworkPreferences const & networkPreferences () const override
 
void setNetworkPreferences (p2p::NetworkPreferences const &_n, bool _dropPeers=false) override
 
p2p::NodeInfo nodeInfo () const override
 Get information concerning this node. More...
 
p2p::NodeID id () const override
 
u256 networkId () const override
 Get network id. More...
 
std::string enode () const override
 Get enode string. More...
 
p2p::Peers nodes () const override
 Gets the nodes. 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...
 

Static Public Member Functions

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

Private Attributes

std::string m_clientVersion
 Our end-application client's name/version. More...
 
p2p::Host m_net
 Should run in background and send us events when blocks found and allow us to send blocks as required. More...
 
std::unique_ptr< eth::Clientm_ethereum
 Client for Ethereum ("eth") protocol. More...
 
std::weak_ptr< shh::WhisperHostm_whisper
 Client for Whisper ("shh") protocol. More...
 

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 119 of file WebThree.h.

Constructor & Destructor Documentation

WebThreeDirect::WebThreeDirect ( std::string const &  _clientVersion,
std::string const &  _dbPath,
eth::ChainParams const &  _params,
WithExisting  _we = WithExisting::Trust,
std::set< std::string > const &  _interfaces = {"eth", "shh", "bzz"},
p2p::NetworkPreferences const &  _n = p2p::NetworkPreferences(),
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 39 of file WebThree.cpp.

Here is the call graph for this function:

WebThreeDirect::~WebThreeDirect ( )

Destructor.

Definition at line 77 of file WebThree.cpp.

Here is the call graph for this function:

Member Function Documentation

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

Add node to connect to.

Implements dev::NetworkFace.

Definition at line 145 of file WebThree.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Add node to connect to.

Definition at line 163 of file WebThree.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Add node to connect to.

Definition at line 166 of file WebThree.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Add node to connect to.

Definition at line 169 of file WebThree.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Generalised peer addition.

Implements dev::NetworkFace.

Definition at line 155 of file WebThree.cpp.

Here is the call graph for this function:

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

Definition at line 146 of file WebThree.h.

Here is the caller graph for this function:

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

Definition at line 93 of file WebThree.cpp.

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

Get enode string.

Implements dev::NetworkFace.

Definition at line 198 of file WebThree.h.

Here is the caller graph for this function:

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

Definition at line 140 of file WebThree.h.

Here is the caller graph for this function:

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

Implements dev::NetworkFace.

Definition at line 186 of file WebThree.h.

p2p::NodeID dev::WebThreeDirect::id ( ) const
inlineoverridevirtual

Implements dev::NetworkFace.

Definition at line 194 of file WebThree.h.

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

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

Implements dev::NetworkFace.

Definition at line 210 of file WebThree.h.

Here is the caller graph for this function:

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

Get network id.

Implements dev::NetworkFace.

Definition at line 196 of file WebThree.h.

p2p::NetworkPreferences const & WebThreeDirect::networkPreferences ( ) const
overridevirtual

Implements dev::NetworkFace.

Definition at line 105 of file WebThree.cpp.

Here is the call graph for this function:

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

Get information concerning this node.

Implements dev::NetworkFace.

Definition at line 192 of file WebThree.h.

p2p::Peers dev::WebThreeDirect::nodes ( ) const
inlineoverridevirtual

Gets the nodes.

Implements dev::NetworkFace.

Definition at line 201 of file WebThree.h.

size_t WebThreeDirect::peerCount ( ) const
overridevirtual

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

Implements dev::NetworkFace.

Definition at line 125 of file WebThree.cpp.

Here is the call graph for this function:

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

Get information on the current peer set.

Implements dev::NetworkFace.

Definition at line 120 of file WebThree.cpp.

Here is the call graph for this function:

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

Require connection to peer.

Implements dev::NetworkFace.

Definition at line 150 of file WebThree.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Require connection to peer.

Definition at line 175 of file WebThree.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bytes WebThreeDirect::saveNetwork ( )
overridevirtual

Save peers.

Implements dev::NetworkFace.

Definition at line 140 of file WebThree.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void WebThreeDirect::setIdealPeerCount ( size_t  _n)
overridevirtual

Sets the ideal number of peers.

Implements dev::NetworkFace.

Definition at line 130 of file WebThree.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void WebThreeDirect::setNetworkPreferences ( p2p::NetworkPreferences const &  _n,
bool  _dropPeers = false 
)
overridevirtual

Implements dev::NetworkFace.

Definition at line 110 of file WebThree.cpp.

Here is the call graph for this function:

void WebThreeDirect::setPeerStretch ( size_t  _n)

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

Definition at line 135 of file WebThree.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void dev::WebThreeDirect::startNetwork ( )
inlineoverridevirtual

Start the network subsystem.

Implements dev::NetworkFace.

Definition at line 204 of file WebThree.h.

Here is the caller graph for this function:

void dev::WebThreeDirect::stopNetwork ( )
inlineoverridevirtual

Stop the network subsystem.

Implements dev::NetworkFace.

Definition at line 207 of file WebThree.h.

Here is the caller graph for this function:

std::shared_ptr<shh::WhisperHost> dev::WebThreeDirect::whisper ( ) const
inline

Definition at line 141 of file WebThree.h.

Here is the caller graph for this function:

Member Data Documentation

std::string dev::WebThreeDirect::m_clientVersion
private

Our end-application client's name/version.

Definition at line 213 of file WebThree.h.

std::unique_ptr<eth::Client> dev::WebThreeDirect::m_ethereum
private

Client for Ethereum ("eth") protocol.

Definition at line 217 of file WebThree.h.

p2p::Host dev::WebThreeDirect::m_net
private

Should run in background and send us events when blocks found and allow us to send blocks as required.

Definition at line 215 of file WebThree.h.

std::weak_ptr<shh::WhisperHost> dev::WebThreeDirect::m_whisper
private

Client for Whisper ("shh") protocol.

Definition at line 218 of file WebThree.h.


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