 |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
Go to the documentation of this file.
8 #include <libp2p/Capability.h>
9 #include <libp2p/CapabilityHost.h>
15 class SnapshotStorageFace;
73 u256 const& _networkId, boost::filesystem::path
const& _snapshotDownloadPath,
74 std::shared_ptr<SnapshotStorageFace> _snapshotStorage);
76 std::string
name()
const override {
return "par"; }
93 u256 const& _hostNetworkId,
u256 const& _chainTotalDifficulty,
94 h256 const& _chainCurrentHash,
h256 const& _chainGenesisHash,
95 h256 const& _snapshotBlockHash,
u256 const& _snapshotBlockNumber);
97 unsigned _skip,
bool _reverse);
103 std::vector<unsigned>
const& _protocolVersions,
u256 const& _networkId);
108 static constexpr std::chrono::milliseconds c_backgroundWorkInterval{1000};
110 std::shared_ptr<WarpPeerObserverFace> createPeerObserver(
111 boost::filesystem::path
const& _snapshotDownloadPath);
117 std::shared_ptr<p2p::CapabilityHostFace> m_host;
119 BlockChain
const& m_blockChain;
120 u256 const m_networkId;
122 std::shared_ptr<SnapshotStorageFace> m_snapshot;
123 std::shared_ptr<WarpPeerObserverFace> m_peerObserver;
125 std::unordered_map<NodeID, WarpPeerStatus> m_peers;
virtual void onPeerBlockHeaders(NodeID const &_peerID, RLP const &_r)=0
u256 m_networkId
Peer's network id.
time_t m_lastAsk
When we asked for it. Allows a time out.
h256 m_latestHash
These are determined through either a Status message.
h256 m_genesisHash
Peer's genesis hash.
bool requestData(NodeID const &_peerID, h256 const &_chunkHash)
virtual void onPeerData(NodeID const &_peerID, RLP const &_r)=0
unsigned version() const override
void requestManifest(NodeID const &_peerID)
bool interpretCapabilityPacket(NodeID const &_peerID, unsigned _id, RLP const &) override
WarpSubprotocolPacketType
virtual void onPeerStatus(NodeID const &_peerID)=0
void requestStatus(NodeID const &_peerID, unsigned _hostProtocolVersion, u256 const &_hostNetworkId, u256 const &_chainTotalDifficulty, h256 const &_chainCurrentHash, h256 const &_chainGenesisHash, h256 const &_snapshotBlockHash, u256 const &_snapshotBlockNumber)
p2p::CapabilityHostFace & capabilityHost()
WarpCapability(std::shared_ptr< p2p::CapabilityHostFace > _host, BlockChain const &_blockChain, u256 const &_networkId, boost::filesystem::path const &_snapshotDownloadPath, std::shared_ptr< SnapshotStorageFace > _snapshotStorage)
void onConnect(NodeID const &_peerID, u256 const &_peerCapabilityVersion) override
void doBackgroundWork() override
std::chrono::milliseconds backgroundWorkInterval() const override
u256 m_totalDifficulty
Peer's latest block's total difficulty.
std::string name() const override
@ WarpSubprotocolPacketCount
virtual ~WarpPeerObserverFace()
unsigned const c_WarpProtocolVersion
Implements the blockchain database. All data this gives is disk-backed. @threadsafe.
void requestBlockHeaders(NodeID const &_peerID, unsigned _startNumber, unsigned _count, unsigned _skip, bool _reverse)
virtual void onPeerManifest(NodeID const &_peerID, RLP const &_r)=0
unsigned m_protocolVersion
Peer's protocol version.
void onDisconnect(NodeID const &_peerID) override
virtual void onPeerDisconnect(NodeID const &_peerID, Asking _asking)=0
bool validateStatus(NodeID const &_peerID, h256 const &_genesisHash, std::vector< unsigned > const &_protocolVersions, u256 const &_networkId)
Validates whether peer is able to communicate with the host, disables peer if not.
p2p::CapDesc descriptor() const override
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
unsigned messageCount() const override
Asking m_asking
What, if anything, we last asked the other peer for.
void disablePeer(NodeID const &_peerID, std::string const &_problem)