32 #include <boost/asio.hpp> 33 #include <boost/asio/ip/tcp.hpp> 160 std::map<std::string, std::string>
notes;
191 operator bi::udp::endpoint()
const {
return bi::udp::endpoint(
address, udpPort); }
192 operator bi::tcp::endpoint()
const {
return bi::tcp::endpoint(
address, tcpPort); }
194 operator bool()
const {
return !
address.is_unspecified() && udpPort > 0 && tcpPort > 0; }
206 void interpretRLP(
RLP const& _r);
210 uint16_t udpPort = 0;
211 uint16_t tcpPort = 0;
221 NodeSpec(std::string
const& _addr, uint16_t _port,
int _udpPort = -1):
224 m_udpPort(_udpPort == -1 ? _port : (uint16_t)_udpPort)
231 std::string enode()
const;
235 uint16_t m_tcpPort = 0;
236 uint16_t m_udpPort = 0;
251 virtual operator bool()
const {
return (
bool)id; }
269 DeadlineOp(ba::io_service& _io,
unsigned _msInFuture,
std::function<
void(boost::system::error_code
const&)>
const& _f): m_timer(new
ba::deadline_timer(_io)) { m_timer->expires_from_now(boost::posix_time::milliseconds(_msInFuture)); m_timer->async_wait(_f); }
277 m_timer.reset(_s.m_timer.release());
281 bool expired() {
Guard l(x_timer);
return m_timer->expires_from_now().total_nanoseconds() <= 0; }
290 DeadlineOps(ba::io_service& _io,
unsigned _reapIntervalMs = 100): m_io(_io), m_reapIntervalMs(_reapIntervalMs), m_stopped(false) { reap(); }
293 void schedule(
unsigned _msInFuture,
std::function<
void(boost::system::error_code
const&)>
const& _f) {
if (m_stopped)
return;
DEV_GUARDED(x_timers) m_timers.emplace_back(m_io, _msInFuture, _f); }
327 return std::hash<unsigned long>()(_a.to_v4().to_ulong());
330 auto const& range = _a.to_v6().to_bytes();
331 return boost::hash_range(range.begin(), range.end());
333 if (_a.is_unspecified())
334 return static_cast<size_t>(0x3487194039229152ull);
335 return std::hash<std::string>()(_a.to_string());
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
#define function(a, b, c, d, k, s)
std::pair< std::string, u256 > CapDesc
bool isPrivateAddress(bi::address const &_addressToCheck)
unsigned const protocolVersion
bool isLocalHostAddress(bi::address const &_addressToCheck)
The Host class Capabilities should be registered prior to startNetwork, since m_capabilities is not t...
std::vector< PeerSessionInfo > PeerSessionInfos
std::map< std::string, std::string > notes
bool isPublicAddress(bi::address const &_addressToCheck)
NodeIPEndpoint(bi::address _addr, uint16_t _udp, uint16_t _tcp)
bool operator!=(NodeIPEndpoint const &_cmp) const
std::hash for asio::adress
assert(len-trim+(2 *lenIndices)<=WIDTH)
const unsigned c_protocolVersion
Peer network protocol version.
std::chrono::steady_clock::duration lastPing
bool operator==(const ::CryptoPP::OID &lhs, const ::CryptoPP::OID &rhs)
Node(Public _publicKey, NodeIPEndpoint const &_ip, PeerType _peerType=PeerType::Optional)
unsigned short const port
#define DEV_GUARDED(MUTEX)
Simple block guard.
bool operator==(NodeIPEndpoint const &_cmp) const
DeadlineOps(ba::io_service &_io, unsigned _reapIntervalMs=100)
std::string reasonOf(DisconnectReason _r)
Base class for all exceptions.
unsigned m_reapIntervalMs
std::lock_guard< std::mutex > Guard
std::atomic< bool > m_stopped
bool isPermanentProblem(DisconnectReason _r)
DeadlineOp(ba::io_service &_io, unsigned _msInFuture, std::function< void(boost::system::error_code const &)> const &_f)
NodeSpec(std::string const &_addr, uint16_t _port, int _udpPort=-1)
const Node UnspecifiedNode
void schedule(unsigned _msInFuture, std::function< void(boost::system::error_code const &)> const &_f)
DeadlineOp(DeadlineOp &&_s)
std::vector< CapDesc > CapDescs
std::unique_ptr< ba::deadline_timer > m_timer
NodeIPEndpoint(RLP const &_r)
std::set< CapDesc > const caps
virtual NodeID const & address() const
std::string const clientVersion
const unsigned c_defaultIPPort
std::set< CapDesc > CapDescSet
virtual Public const & publicKey() const
The default logging channels.
std::vector< DeadlineOp > m_timers
struct evm_uint160be address(struct evm_env *env)
std::ostream & operator<<(std::ostream &_out, NodeTable const &_nodeTable)
Class for writing to an RLP bytestream.
DeadlineOp & operator=(DeadlineOp &&_s)
const NodeIPEndpoint UnspecifiedNodeIPEndpoint
Class for interpreting Recursive Linear-Prefix Data.
size_t operator()(bi::address const &_a) const
static bool test_allowLocal
Setting true causes isAllowed to return true for all addresses. (Used by test fixtures) ...
UniValue stop(const JSONRPCRequest &jsonRequest)
NodeIPEndpoint endpoint
Endpoints by which we expect to reach node.