diff --git a/libp2p/Host.h b/libp2p/Host.h index 37fd8a4eb..34179a3b4 100644 --- a/libp2p/Host.h +++ b/libp2p/Host.h @@ -173,7 +173,7 @@ public: Nodes nodes() const { RecursiveGuard l(x_peers); Nodes ret; for (auto const& i: m_nodes) ret.push_back(*i.second); return ret; } - void setNetworkPreferences(NetworkPreferences const& _p) { stop(); m_netPrefs = _p; start(); } + void setNetworkPreferences(NetworkPreferences const& _p) { auto had = isStarted(); if (had) stop(); m_netPrefs = _p; if (had) start(); } void start(); void stop(); diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index 5a66064f8..67e9e91e9 100644 --- a/libp2p/Session.cpp +++ b/libp2p/Session.cpp @@ -582,7 +582,7 @@ void Session::doRead() // error - bad protocol clogS(NetWarn) << "Couldn't interpret packet." << RLP(r); // Just wasting our bandwidth - perhaps reduce rating? - return; + //return; } } memmove(m_incoming.data(), m_incoming.data() + tlen, m_incoming.size() - tlen); diff --git a/libwebthree/WebThree.cpp b/libwebthree/WebThree.cpp index bbed74c33..b5256ac22 100644 --- a/libwebthree/WebThree.cpp +++ b/libwebthree/WebThree.cpp @@ -65,6 +65,16 @@ WebThreeDirect::~WebThreeDirect() m_ethereum.reset(); } +void WebThreeDirect::setNetworkPreferences(p2p::NetworkPreferences const& _n) +{ + auto had = haveNetwork(); + if (had) + stopNetwork(); + m_net.setNetworkPreferences(_n); + if (had) + startNetwork(); +} + std::vector WebThreeDirect::peers() { return m_net.peers(); diff --git a/libwebthree/WebThree.h b/libwebthree/WebThree.h index a71d30f23..10e965402 100644 --- a/libwebthree/WebThree.h +++ b/libwebthree/WebThree.h @@ -106,7 +106,7 @@ public: bool haveNetwork() const { return m_net.isStarted(); } - void setNetworkPreferences(p2p::NetworkPreferences const& _n) { auto had = haveNetwork(); if (had) stopNetwork(); m_net.setNetworkPreferences(_n); if (had) startNetwork(); } + void setNetworkPreferences(p2p::NetworkPreferences const& _n); p2p::NodeId id() const { return m_net.id(); }