From 646465136559feea504affb1f285ea302de723cd Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 2 Oct 2014 20:10:01 +0200 Subject: [PATCH 1/2] More networking fixes. --- libethereum/EthereumPeer.cpp | 14 ++++++++------ libp2p/Session.cpp | 4 ++-- libp2p/Session.h | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index d6390bdfd..d7d69187d 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -95,7 +95,7 @@ void EthereumPeer::tryGrabbingHashChain() if (td >= m_totalDifficulty) { clogS(NetAllDetail) << "No. Our chain is better."; - m_grabbing = Grabbing::Nothing; + setGrabbing(Grabbing::Nothing); return; // All good - we have the better chain. } @@ -104,7 +104,7 @@ void EthereumPeer::tryGrabbingHashChain() clogS(NetAllDetail) << "Yes. Their chain is better."; host()->updateGrabbing(Grabbing::Hashes); - m_grabbing = Grabbing::Hashes; + setGrabbing(Grabbing::Hashes); RLPStream s; prep(s).appendList(3); s << GetBlockHashesPacket << m_latestHash << c_maxHashesAsk; @@ -144,12 +144,14 @@ bool EthereumPeer::interpret(RLP const& _r) if (genesisHash != host()->m_chain.genesisHash()) disable("Invalid genesis hash"); - if (m_protocolVersion != host()->protocolVersion()) + else if (m_protocolVersion != host()->protocolVersion()) disable("Invalid protocol version."); - if (m_networkId != host()->networkId()) + else if (m_networkId != host()->networkId()) disable("Invalid network identifier."); - - startInitialSync(); + else if (session()->info().clientVersion.find("/v0.6.9/") != string::npos) + disable("Blacklisted client version."); + else + startInitialSync(); break; } case GetTransactionsPacket: diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index e449d03b7..ea8db2127 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), set(), 0}); + m_info = PeerInfo({"?", _peerAddress.to_string(), m_listenPort, std::chrono::steady_clock::duration(0), set(), 0, map()}); } 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(), (unsigned)m_socket.native_handle()}); } + { 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(), map() }); } catch (...) { disconnect(BadProtocol); diff --git a/libp2p/Session.h b/libp2p/Session.h index 64dbd9dac..934e548d4 100644 --- a/libp2p/Session.h +++ b/libp2p/Session.h @@ -73,6 +73,8 @@ public: void addNote(std::string const& _k, std::string const& _v) { m_info.notes[_k] = _v; } + PeerInfo const& info() const { return m_info; } + private: void dropped(); void doRead(); From f1d1dcc628c19031087a7543a54047513a316007 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 3 Oct 2014 13:12:15 +0200 Subject: [PATCH 2/2] Fix windows build? --- alethzero/MainWin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 5df652568..2181098a9 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include