Browse Source

Subtle sync state-change bug that was declaring perfectly fine nodes to

be bad.
cl-refactor
Gav Wood 10 years ago
parent
commit
3ceae64f34
  1. 5
      libethereum/EthereumPeer.cpp
  2. 4
      libp2p/Host.cpp
  3. 2
      libp2p/Session.cpp

5
libethereum/EthereumPeer.cpp

@ -142,7 +142,6 @@ void EthereumPeer::transition(Asking _a, bool _force)
host()->m_man.resetToChain(m_syncingNeededBlocks);
host()->m_latestBlockSent = m_syncingLatestHash;
}
else
{
@ -156,8 +155,8 @@ void EthereumPeer::transition(Asking _a, bool _force)
if (m_asking == Asking::Nothing || m_asking == Asking::Hashes || m_asking == Asking::Blocks)
{
// Looks like it's the best yet for total difficulty. Set to download.
setAsking(Asking::Blocks, true); // will kick off other peers to help if available.
auto blocks = m_sub.nextFetch(c_maxBlocksAsk);
setAsking(Asking::Blocks, isSyncing()); // will kick off other peers to help if available.
auto blocks = m_sub.nextFetch(c_maxBlocksAsk, isSyncing());
if (blocks.size())
{
prep(s, GetBlocksPacket, blocks.size());

4
libp2p/Host.cpp

@ -369,7 +369,7 @@ shared_ptr<Node> Host::noteNode(NodeId _id, bi::tcp::endpoint _a, Origin _o, boo
if (_a.port() < 30300 && _a.port() > 30303)
cwarn << "Wierd port being recorded!";
if (_a.port() >= 49152)
if (_a.port() >= /*49152*/32768)
{
cwarn << "Private port being recorded - setting to 0";
_a = bi::tcp::endpoint(_a.address(), 0);
@ -756,7 +756,7 @@ bytes Host::saveNodes() const
{
Node const& n = *(i.second);
// TODO: PoC-7: Figure out why it ever shares these ports.//n.address.port() >= 30300 && n.address.port() <= 30305 &&
if (!n.dead && n.address.port() > 0 && n.address.port() < 49152 && n.id != id() && !isPrivateAddress(n.address.address()))
if (!n.dead && n.address.port() > 0 && n.address.port() < /*49152*/32768 && n.id != id() && !isPrivateAddress(n.address.address()))
{
nodes.appendList(10);
if (n.address.address().is_v4())

2
libp2p/Session.cpp

@ -335,7 +335,7 @@ bool Session::interpret(RLP const& _r)
if (!ep.port())
goto CONTINUE; // Zero port? Don't think so.
if (ep.port() >= 49152)
if (ep.port() >= /*49152*/32768)
goto CONTINUE; // Private port according to IANA.
// TODO: PoC-7:

Loading…
Cancel
Save