From 340801ed907dc15b4f9c15dc46f93ffd93200fcf Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 30 Sep 2014 15:53:15 +0100 Subject: [PATCH] Networking fixes. --- alethzero/MainWin.cpp | 2 +- libdevcore/Common.cpp | 2 +- libethereum/EthereumHost.cpp | 2 ++ libethereum/EthereumPeer.cpp | 3 ++- libp2p/Common.h | 1 + libp2p/Session.cpp | 4 ++-- test/TestHelper.cpp | 2 ++ 7 files changed, 11 insertions(+), 5 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 664a7f734..14fbf003f 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -711,7 +711,7 @@ void Main::refreshNetwork() ui->peerCount->setText(QString::fromStdString(toString(ps.size())) + " peer(s)"); ui->peers->clear(); for (PeerInfo const& i: ps) - ui->peers->addItem(QString("%3 ms - %1:%2 - %4 %5").arg(i.host.c_str()).arg(i.port).arg(chrono::duration_cast(i.lastPing).count()).arg(i.clientVersion.c_str()).arg(QString::fromStdString(toString(i.caps)))); + ui->peers->addItem(QString("[%6] %3 ms - %1:%2 - %4 %5").arg(i.host.c_str()).arg(i.port).arg(chrono::duration_cast(i.lastPing).count()).arg(i.clientVersion.c_str()).arg(QString::fromStdString(toString(i.caps))).arg(i.socket)); } void Main::refreshAll() diff --git a/libdevcore/Common.cpp b/libdevcore/Common.cpp index 8312960c1..bc903b52d 100644 --- a/libdevcore/Common.cpp +++ b/libdevcore/Common.cpp @@ -27,7 +27,7 @@ using namespace dev; namespace dev { -char const* Version = "0.6.9"; +char const* Version = "0.6.10"; } diff --git a/libethereum/EthereumHost.cpp b/libethereum/EthereumHost.cpp index 74a33f9d5..eea3fd5af 100644 --- a/libethereum/EthereumHost.cpp +++ b/libethereum/EthereumHost.cpp @@ -265,6 +265,8 @@ void EthereumHost::maintainBlocks(BlockQueue& _bq, h256 _currentHash) ++c; } clog(NetMessageSummary) << "Sending" << c << "new blocks (current is" << _currentHash << ", was" << m_latestBlockSent << ")"; + if (c > 1000) + cwarn << "Gaa sending an awful lot of new blocks. Sure this is right?"; ts.appendList(1 + c).append(BlocksPacket).appendRaw(bs, c); bytes b; ts.swapOut(b); diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index 7950c489f..fb2558d57 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -264,7 +264,8 @@ bool EthereumPeer::interpret(RLP const& _r) unsigned unknownParents = 0; if (g_logVerbosity >= NetMessageSummary::verbosity) { - for (unsigned i = 1; i < _r.itemCount(); ++i) + unsigned ic = _r.itemCount(); + for (unsigned i = 1; i < ic; ++i) { auto h = BlockInfo::headerHash(_r[i].data()); BlockInfo bi(_r[i].data()); diff --git a/libp2p/Common.h b/libp2p/Common.h index a83ac03de..3339df8bb 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -95,6 +95,7 @@ struct PeerInfo unsigned short port; std::chrono::steady_clock::duration lastPing; std::set caps; + unsigned socket; }; } diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index 2dc60e0de..e449d03b7 100644 --- a/libp2p/Session.cpp +++ b/libp2p/Session.cpp @@ -40,7 +40,7 @@ Session::Session(Host* _s, bi::tcp::socket _socket, bi::address _peerAddress, un { m_disconnect = std::chrono::steady_clock::time_point::max(); m_connect = std::chrono::steady_clock::now(); - m_info = PeerInfo({"?", _peerAddress.to_string(), m_listenPort, std::chrono::steady_clock::duration(0)}); + m_info = PeerInfo({"?", _peerAddress.to_string(), m_listenPort, std::chrono::steady_clock::duration(0), set(), 0}); } Session::~Session() @@ -102,7 +102,7 @@ bool Session::interpret(RLP const& _r) return false; } try - { m_info = PeerInfo({clientVersion, m_socket.remote_endpoint().address().to_string(), m_listenPort, std::chrono::steady_clock::duration(), _r[3].toSet()}); } + { m_info = PeerInfo({clientVersion, m_socket.remote_endpoint().address().to_string(), m_listenPort, std::chrono::steady_clock::duration(), _r[3].toSet(), (unsigned)m_socket.native_handle()}); } catch (...) { disconnect(BadProtocol); diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 20c42a9b8..03e679343 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -42,6 +42,8 @@ void mine(Client& c, int numBlocks) void connectClients(Client& c1, Client& c2) { + (void)c1; + (void)c2; // TODO: Move to WebThree. eth::Client no longer handles networking. #if 0 short c1Port = 20000;