Browse Source

Block hash download fix.

cl-refactor
Gav Wood 10 years ago
parent
commit
95c063202c
  1. 7
      libethereum/EthereumHost.cpp
  2. 10
      libwhisper/WhisperPeer.cpp

7
libethereum/EthereumHost.cpp

@ -74,13 +74,20 @@ void EthereumHost::noteHavePeerState(EthereumPeer* _who)
{ {
clog(NetAllDetail) << "Have peer state."; clog(NetAllDetail) << "Have peer state.";
// TODO: FIX: BUG: Better state management!
// if already downloading hash-chain, ignore. // if already downloading hash-chain, ignore.
if (m_grabbing != Grabbing::Nothing) if (m_grabbing != Grabbing::Nothing)
{
for (auto const& i: peers())
if (i->cap<EthereumPeer>()->m_grabbing == m_grabbing || m_grabbing == Grabbing::State)
{ {
clog(NetAllDetail) << "Already downloading chain. Just set to help out."; clog(NetAllDetail) << "Already downloading chain. Just set to help out.";
_who->ensureGettingChain(); _who->ensureGettingChain();
return; return;
} }
m_grabbing = Grabbing::Nothing;
}
// otherwise check to see if we should be downloading... // otherwise check to see if we should be downloading...
_who->tryGrabbingHashChain(); _who->tryGrabbingHashChain();

10
libwhisper/WhisperPeer.cpp

@ -92,16 +92,18 @@ void WhisperPeer::sendMessages()
n++; n++;
} }
// pause before sending if no messages to send if (n)
if (!n) {
this_thread::sleep_for(chrono::milliseconds(100));
RLPStream s; RLPStream s;
prep(s); prep(s);
s.appendList(n + 1) << MessagesPacket; s.appendList(n + 1) << MessagesPacket;
s.appendRaw(amalg.out(), n); s.appendRaw(amalg.out(), n);
sealAndSend(s); sealAndSend(s);
} }
else
// just pause if no messages to send
this_thread::sleep_for(chrono::milliseconds(100));
}
void WhisperPeer::noteNewMessage(h256 _h, Message const& _m) void WhisperPeer::noteNewMessage(h256 _h, Message const& _m)
{ {

Loading…
Cancel
Save