Browse Source

Avoid overwriting messages with same expiry.

cl-refactor
Gav Wood 10 years ago
parent
commit
1e0684c1b4
  1. 1
      libwhisper/Message.cpp
  2. 2
      libwhisper/WhisperHost.cpp
  3. 2
      libwhisper/WhisperHost.h
  4. 2
      libwhisper/WhisperPeer.cpp
  5. 2
      libwhisper/WhisperPeer.h

1
libwhisper/Message.cpp

@ -91,7 +91,6 @@ Envelope Message::seal(Secret _from, Topic const& _topic, unsigned _ttl, unsigne
Envelope::Envelope(RLP const& _m)
{
cdebug << _m;
m_expiry = _m[0].toInt<unsigned>();
m_ttl = _m[1].toInt<unsigned>();
m_topic = _m[2].toVector<FixedHash<4>>();

2
libwhisper/WhisperHost.cpp

@ -68,7 +68,7 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p)
return;
UpgradeGuard ll(l);
m_messages[h] = _m;
m_expiryQueue[_m.expiry()] = h;
m_expiryQueue.insert(make_pair(_m.expiry(), h));
}
// if (_p)

2
libwhisper/WhisperHost.h

@ -78,7 +78,7 @@ private:
mutable dev::SharedMutex x_messages;
std::map<h256, Envelope> m_messages;
std::map<unsigned, h256> m_expiryQueue;
std::multimap<unsigned, h256> m_expiryQueue;
mutable dev::Mutex m_filterLock;
std::map<h256, InstalledFilter> m_filters;

2
libwhisper/WhisperPeer.cpp

@ -106,5 +106,5 @@ void WhisperPeer::sendMessages()
void WhisperPeer::noteNewMessage(h256 _h, Message const& _m)
{
Guard l(x_unseen);
m_unseen[rating(_m)] = _h;
m_unseen.insert(make_pair(rating(_m), _h));
}

2
libwhisper/WhisperPeer.h

@ -67,7 +67,7 @@ private:
void noteNewMessage(h256 _h, Message const& _m);
mutable dev::Mutex x_unseen;
std::map<unsigned, h256> m_unseen; ///< Rated according to what they want.
std::multimap<unsigned, h256> m_unseen; ///< Rated according to what they want.
std::chrono::system_clock::time_point m_timer = std::chrono::system_clock::now();
};

Loading…
Cancel
Save