31 WhisperPeer::WhisperPeer(std::shared_ptr<SessionFace> _s, HostCapabilityFace* _h,
unsigned _i,
CapDesc const&, uint16_t _capID):
32 Capability(_s, _h, _i, _capID)
45 return static_cast<WhisperHost*
>(Capability::hostCapability());
54 auto protocolVersion = _r[0].
toInt<
unsigned>();
58 if (protocolVersion !=
version())
59 disable(
"Invalid protocol version.");
61 for (
auto const& m:
host()->all())
64 m_unseen.insert(make_pair(0, m.first));
67 if (session()->
id() <
host()->
host()->
id())
95 multimap<unsigned, h256> available;
102 for (
auto i = available.rbegin(); i != available.rend(); ++i)
105 unsigned msgCount = available.size();
118 m_unseen.insert(make_pair(rate, _h));
135 unsigned ttlReward = (256 > e.
ttl() ? 256 - e.
ttl() : 0);
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
WhisperHost * host() const
virtual void inject(Envelope const &_e, WhisperPeer *_from=nullptr) override
unsigned ratingForPeer(Envelope const &e) const
std::pair< std::string, u256 > CapDesc
void streamMessage(h256 _m, RLPStream &_s) const
bytes const & out() const
Read the byte stream.
virtual bool interpret(unsigned _id, RLP const &) override
std::hash for asio::adress
dev::Mutex x_advertiseTopicsOfInterest
std::multimap< unsigned, h256 > m_unseen
Rated according to what they want.
TopicBloomFilterHash bloom() const
#define DEV_GUARDED(MUTEX)
Simple block guard.
std::lock_guard< std::mutex > Guard
void noteAdvertiseTopicsOfInterest()
void setBloom(TopicBloomFilterHash const &_b)
unsigned workProved() const
bool matchesBloomFilter(TopicBloomFilterHash const &f) const
void noteNewMessage(h256 _h, Envelope const &_m)
void sendTopicsOfInterest(TopicBloomFilterHash const &_bloom)
sends our bloom filter to remote peer
bool m_advertiseTopicsOfInterest
_T toInt(int _flags=Strict) const
Converts to int of type given; if isString(), decodes as big-endian bytestream.
Class for writing to an RLP bytestream.
RLPStream & appendRaw(bytesConstRef _rlp, size_t _itemCount=1)
Appends raw (pre-serialised) RLP data. Use with caution.
Class for interpreting Recursive Linear-Prefix Data.