From aaec62722eaa5b1fca050ee1c9ac1d9e0ea49c4a Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Tue, 23 Jun 2015 13:56:34 +0200 Subject: [PATCH] protocol changed --- libwhisper/Common.cpp | 6 +++--- libwhisper/WhisperHost.cpp | 5 +---- libwhisper/WhisperPeer.cpp | 14 +++++++++----- libwhisper/WhisperPeer.h | 3 +-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libwhisper/Common.cpp b/libwhisper/Common.cpp index 32acbdd8e..79c87b96f 100644 --- a/libwhisper/Common.cpp +++ b/libwhisper/Common.cpp @@ -95,12 +95,12 @@ TopicFilter::TopicFilter(RLP const& _r) } } -FixedHash TopicFilter::exportBloom() const +FixedHash TopicFilter::exportBloom() const { - FixedHash ret; + FixedHash ret; for (TopicMask const& t: m_topicMasks) for (auto const& i: t) - ret |= i.first.template bloomPart(); + ret |= i.first.template bloomPart(); return ret; } diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 2cccb0151..cf33e2e81 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -88,10 +88,7 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) void WhisperHost::advertizeTopicsOfInterest() { for (auto i: peerSessions()) - { - auto w = i.first->cap().get(); - w->advertizeTopicsOfInterest(m_bloom); - } + i.first->cap().get()->advertizeTopicsOfInterest(); } void WhisperHost::noteChanged(h256 _messageHash, h256 _filter) diff --git a/libwhisper/WhisperPeer.cpp b/libwhisper/WhisperPeer.cpp index 826b7842d..7ac08aa41 100644 --- a/libwhisper/WhisperPeer.cpp +++ b/libwhisper/WhisperPeer.cpp @@ -31,6 +31,7 @@ using namespace dev::shh; WhisperPeer::WhisperPeer(std::shared_ptr _s, HostCapabilityFace* _h, unsigned _i, CapDesc const&): Capability(_s, _h, _i) { RLPStream s; + //sealAndSend(prep(s, StatusPacket, 1) << version()); prep(s, StatusPacket, 2); s << version(); s << host()->bloom(); @@ -58,9 +59,12 @@ bool WhisperPeer::interpret(unsigned _id, RLP const& _r) if (protocolVersion != version()) disable("Invalid protocol version."); - - if (_r.itemCount() > 1) // for backwards compatibility - m_bloom = (FixedHash)_r[1]; + else + { + if (_r.itemCount() > 1) // for backwards compatibility + m_bloom = (FixedHash)_r[1]; + advertizeTopicsOfInterest(); + } for (auto const& m: host()->all()) m_unseen.insert(make_pair(0, m.first)); @@ -115,10 +119,10 @@ void WhisperPeer::noteNewMessage(h256 _h, Envelope const& _m) m_unseen.insert(make_pair(rating(_m), _h)); } -void WhisperPeer::advertizeTopicsOfInterest(FixedHash const& _bloom) +void WhisperPeer::advertizeTopicsOfInterest() { RLPStream s; prep(s, UpdateTopicFilterPacket, 1); - s << _bloom; + s << host()->bloom(); sealAndSend(s); } diff --git a/libwhisper/WhisperPeer.h b/libwhisper/WhisperPeer.h index 95b4a1952..3a2c879ee 100644 --- a/libwhisper/WhisperPeer.h +++ b/libwhisper/WhisperPeer.h @@ -56,8 +56,7 @@ public: static u256 version() { return 2; } static unsigned messageCount() { return PacketCount; } FixedHash const& bloom() const { return m_bloom; } - void advertizeTopicsOfInterest(FixedHash const& _bloom); ///< sends our bloom filter to remote peer - FixedHash const& bloom() { return m_bloom; } + void advertizeTopicsOfInterest(); ///< sends our bloom filter to remote peer private: virtual bool interpret(unsigned _id, RLP const&) override;