Browse Source

Avoid effective disconnect when ignoring data.

cl-refactor
Gav Wood 10 years ago
parent
commit
8f769eae05
  1. 2
      libp2p/Host.h
  2. 2
      libp2p/Session.cpp
  3. 10
      libwebthree/WebThree.cpp
  4. 2
      libwebthree/WebThree.h

2
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();

2
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);

10
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<PeerInfo> WebThreeDirect::peers()
{
return m_net.peers();

2
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(); }

Loading…
Cancel
Save