From eb946bb1edbbefdf96699e6fdb691bd555c71975 Mon Sep 17 00:00:00 2001 From: subtly Date: Fri, 24 Apr 2015 12:23:27 +0100 Subject: [PATCH] cleanup --- libp2p/NodeTable.cpp | 8 +++----- libp2p/NodeTable.h | 6 +++--- libp2p/UDP.h | 2 -- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index 2f69d606d..ad006e837 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -414,8 +414,6 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes { Pong in = Pong::fromBytesConstRef(_from, rlpBytes); - // TODO: check echo! (pending pings) - // whenever a pong is received, check if it's in m_evictions Guard le(x_evictions); bool evictionEntry = false; @@ -451,7 +449,7 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes } // update our endpoint address and UDP port - if ((!m_node.endpoint || !m_node.endpoint.isAllowed()) && in.destination.address != m_node.endpoint.address && isPublicAddress(in.destination.address)) + if ((!m_node.endpoint || !m_node.endpoint.isAllowed()) && isPublicAddress(in.destination.address)) m_node.endpoint.address = in.destination.address; m_node.endpoint.udpPort = in.destination.udpPort; @@ -516,7 +514,7 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes clog(NodeTableTriviaSummary) << "Received expired PingNode from " << _from.address().to_string() << ":" << _from.port(); return; } - + in.source.address = _from.address(); in.source.udpPort = _from.port(); addNode(Node(nodeid, in.source)); @@ -610,7 +608,7 @@ void PingNode::interpretRLP(bytesConstRef _bytes) version = dev::p2p::c_protocolVersion; source.interpretRLP(r[1]); destination.interpretRLP(r[2]); - ts = r[3].toInt(RLP::Strict); + ts = r[3].toInt(RLP::Strict); } else version = 0; diff --git a/libp2p/NodeTable.h b/libp2p/NodeTable.h index 94bf81924..8c1d10a38 100644 --- a/libp2p/NodeTable.h +++ b/libp2p/NodeTable.h @@ -330,7 +330,7 @@ struct Pong: RLPXDatagram uint32_t ts; void streamRLP(RLPStream& _s) const { _s.appendList(2); _s << echo << ts; } - void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); echo = (h256)r[0]; ts = r[1].toInt(); } + void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); echo = (h256)r[0]; ts = r[1].toInt(); } }; /** @@ -356,7 +356,7 @@ struct FindNode: RLPXDatagram uint32_t ts; void streamRLP(RLPStream& _s) const { _s.appendList(2); _s << target << ts; } - void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); target = r[0].toHash(); ts = r[1].toInt(); } + void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); target = r[0].toHash(); ts = r[1].toInt(); } }; /** @@ -386,7 +386,7 @@ struct Neighbours: RLPXDatagram uint32_t ts = 1; void streamRLP(RLPStream& _s) const { _s.appendList(2); _s.appendList(neighbours.size()); for (auto& n: neighbours) n.streamRLP(_s); _s << ts; } - void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); for (auto n: r[0]) neighbours.push_back(Neighbour(n)); ts = r[1].toInt(); } + void interpretRLP(bytesConstRef _bytes) { RLP r(_bytes); for (auto n: r[0]) neighbours.push_back(Neighbour(n)); ts = r[1].toInt(); } }; struct NodeTableWarn: public LogChannel { static const char* name(); static const int verbosity = 0; }; diff --git a/libp2p/UDP.h b/libp2p/UDP.h index cdf241566..ee9875cf7 100644 --- a/libp2p/UDP.h +++ b/libp2p/UDP.h @@ -61,8 +61,6 @@ protected: */ struct RLPXDatagramFace: public UDPDatagram { - static uint32_t futureFromEpoch(std::chrono::milliseconds _ms) { return std::chrono::duration_cast((std::chrono::system_clock::now() + _ms).time_since_epoch()).count(); } - static uint32_t futureFromEpoch(std::chrono::seconds _sec) { return std::chrono::duration_cast((std::chrono::system_clock::now() + _sec).time_since_epoch()).count(); } static uint32_t secondsSinceEpoch() { return std::chrono::duration_cast((std::chrono::system_clock::now()).time_since_epoch()).count(); } static Public authenticate(bytesConstRef _sig, bytesConstRef _rlp);