Browse Source

mutex added

cl-refactor
Vlad Gluhovsky 10 years ago
parent
commit
9ba48b4628
  1. 1
      libwhisper/Common.h
  2. 2
      libwhisper/WhisperHost.h
  3. 3
      libwhisper/WhisperPeer.cpp
  4. 5
      libwhisper/WhisperPeer.h

1
libwhisper/Common.h

@ -59,6 +59,7 @@ enum WhisperPacket
};
enum { TopicBloomFilterSize = 64 };
enum { WhisperProtocolVersion = 2 };
using AbridgedTopic = FixedHash<4>;
using Topic = h256;

2
libwhisper/WhisperHost.h

@ -50,7 +50,7 @@ class WhisperHost: public HostCapability<WhisperPeer>, public Interface, public
public:
WhisperHost();
virtual ~WhisperHost();
unsigned protocolVersion() const { return 2; }
unsigned protocolVersion() const { return WhisperProtocolVersion; }
void cleanup(); ///< remove old messages
std::map<h256, Envelope> all() const { dev::ReadGuard l(x_messages); return m_messages; }
FixedHash<TopicBloomFilterSize> bloom() const { dev::Guard l(m_filterLock); return m_bloom; }

3
libwhisper/WhisperPeer.cpp

@ -117,10 +117,11 @@ void WhisperPeer::noteNewMessage(h256 _h, Envelope const& _m)
void WhisperPeer::sendTopicsOfInterest(FixedHash<TopicBloomFilterSize> const& _bloom)
{
Guard g(x_advertiseTopicsOfInterest);
RLPStream s;
prep(s, TopicFilterPacket, 1);
s << _bloom;
sealAndSend(s);
m_advertiseTopicsOfInterest = false;
}

5
libwhisper/WhisperPeer.h

@ -53,11 +53,11 @@ public:
virtual ~WhisperPeer();
WhisperHost* host() const;
static std::string name() { return "shh"; }
static u256 version() { return 3; }
static u256 version() { return WhisperProtocolVersion; }
static unsigned messageCount() { return PacketCount; }
FixedHash<TopicBloomFilterSize> bloom() const { dev::Guard g(x_bloom); return m_bloom; }
void sendTopicsOfInterest(FixedHash<TopicBloomFilterSize> const& _bloom); ///< sends our bloom filter to remote peer
void noteAdvertiseTopicsOfInterest() { m_advertiseTopicsOfInterest = true; }
void noteAdvertiseTopicsOfInterest() { dev::Guard g(x_advertiseTopicsOfInterest); m_advertiseTopicsOfInterest = true; }
private:
virtual bool interpret(unsigned _id, RLP const&) override;
@ -73,6 +73,7 @@ private:
mutable dev::Mutex x_bloom;
FixedHash<TopicBloomFilterSize> m_bloom; ///< Peer's topics of interest
mutable dev::Mutex x_advertiseTopicsOfInterest;
bool m_advertiseTopicsOfInterest;
};

Loading…
Cancel
Save