diff --git a/libethereum/EthereumHost.cpp b/libethereum/EthereumHost.cpp index de0e991e6..e7e80c28a 100644 --- a/libethereum/EthereumHost.cpp +++ b/libethereum/EthereumHost.cpp @@ -74,12 +74,19 @@ void EthereumHost::noteHavePeerState(EthereumPeer* _who) { clog(NetAllDetail) << "Have peer state."; + // TODO: FIX: BUG: Better state management! + // if already downloading hash-chain, ignore. if (m_grabbing != Grabbing::Nothing) { - clog(NetAllDetail) << "Already downloading chain. Just set to help out."; - _who->ensureGettingChain(); - return; + for (auto const& i: peers()) + if (i->cap()->m_grabbing == m_grabbing || m_grabbing == Grabbing::State) + { + clog(NetAllDetail) << "Already downloading chain. Just set to help out."; + _who->ensureGettingChain(); + return; + } + m_grabbing = Grabbing::Nothing; } // otherwise check to see if we should be downloading... diff --git a/libwhisper/WhisperPeer.cpp b/libwhisper/WhisperPeer.cpp index 4baccdf9c..e92e2cac3 100644 --- a/libwhisper/WhisperPeer.cpp +++ b/libwhisper/WhisperPeer.cpp @@ -92,15 +92,17 @@ void WhisperPeer::sendMessages() n++; } - // pause before sending if no messages to send - if (!n) + if (n) + { + RLPStream s; + prep(s); + s.appendList(n + 1) << MessagesPacket; + s.appendRaw(amalg.out(), n); + sealAndSend(s); + } + else + // just pause if no messages to send this_thread::sleep_for(chrono::milliseconds(100)); - - RLPStream s; - prep(s); - s.appendList(n + 1) << MessagesPacket; - s.appendRaw(amalg.out(), n); - sealAndSend(s); } void WhisperPeer::noteNewMessage(h256 _h, Message const& _m)