|
|
@ -47,7 +47,7 @@ class Watch; |
|
|
|
|
|
|
|
struct InstalledFilter |
|
|
|
{ |
|
|
|
InstalledFilter(FullTopic const& _f): full(_f), filter(fullToFilter(_f)) {} |
|
|
|
InstalledFilter(FullTopic const& _f): full(_f), filter(_f) {} |
|
|
|
|
|
|
|
FullTopic full; |
|
|
|
TopicFilter filter; |
|
|
@ -66,13 +66,12 @@ struct ClientWatch |
|
|
|
class Interface |
|
|
|
{ |
|
|
|
public: |
|
|
|
virtual ~Interface() {} |
|
|
|
virtual ~Interface(); |
|
|
|
|
|
|
|
virtual void inject(Envelope const& _m, WhisperPeer* _from = nullptr) = 0; |
|
|
|
|
|
|
|
unsigned installWatch(TopicMask const& _mask); |
|
|
|
virtual FullTopic getFilter(unsigned _id) const = 0; |
|
|
|
virtual unsigned installWatch(FullTopic const& _filter) = 0; |
|
|
|
virtual unsigned installWatch(FullTopic const& _mask) = 0; |
|
|
|
virtual unsigned installWatchOnId(h256 _filterId) = 0; |
|
|
|
virtual void uninstallWatch(unsigned _watchId) = 0; |
|
|
|
virtual h256s peekWatch(unsigned _watchId) const = 0; |
|
|
@ -81,10 +80,10 @@ public: |
|
|
|
|
|
|
|
virtual Envelope envelope(h256 _m) const = 0; |
|
|
|
|
|
|
|
void post(bytes const& _payload, Topic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).seal(_topic, _ttl, _workToProve)); } |
|
|
|
void post(Public _to, bytes const& _payload, Topic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).sealTo(_to, _topic, _ttl, _workToProve)); } |
|
|
|
void post(Secret _from, bytes const& _payload, Topic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).seal(_from, _topic, _ttl, _workToProve)); } |
|
|
|
void post(Secret _from, Public _to, bytes const& _payload, Topic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).sealTo(_from, _to, _topic, _ttl, _workToProve)); } |
|
|
|
void post(bytes const& _payload, FullTopic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).seal(_topic, _ttl, _workToProve)); } |
|
|
|
void post(Public _to, bytes const& _payload, FullTopic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).sealTo(_to, _topic, _ttl, _workToProve)); } |
|
|
|
void post(Secret _from, bytes const& _payload, FullTopic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).seal(_from, _topic, _ttl, _workToProve)); } |
|
|
|
void post(Secret _from, Public _to, bytes const& _payload, FullTopic _topic, unsigned _ttl = 50, unsigned _workToProve = 50) { inject(Message(_payload).sealTo(_from, _to, _topic, _ttl, _workToProve)); } |
|
|
|
}; |
|
|
|
|
|
|
|
struct WatshhChannel: public dev::LogChannel { static const char* name() { return "shh"; } static const int verbosity = 1; }; |
|
|
@ -106,11 +105,10 @@ class Watch: public boost::noncopyable |
|
|
|
|
|
|
|
public: |
|
|
|
Watch() {} |
|
|
|
Watch(Interface& _c, TopicMask const& _f): m_c(&_c), m_id(_c.installWatch(_f)) {} |
|
|
|
Watch(Interface& _c, TopicFilter const& _tf): m_c(&_c), m_id(_c.installWatch(_tf)) {} |
|
|
|
Watch(Interface& _c, FullTopic const& _f): m_c(&_c), m_id(_c.installWatch(_f)) {} |
|
|
|
~Watch() { if (m_c) m_c->uninstallWatch(m_id); } |
|
|
|
|
|
|
|
FullTopic fullTopic() const { return m_c ? m_c->fullTopic(m_id) : FullTopic(); } |
|
|
|
FullTopic fullTopic() const { return m_c ? m_c->getFilter(m_id) : FullTopic(); } |
|
|
|
h256s check() { return m_c ? m_c->checkWatch(m_id) : h256s(); } |
|
|
|
h256s peek() { return m_c ? m_c->peekWatch(m_id) : h256s(); } |
|
|
|
|
|
|
|