diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 4e438b1f6..d9deab8e4 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -75,7 +75,7 @@ public: dev::WebThreeDirect* web3() const { return m_webThree.get(); } dev::eth::Client* ethereum() const { return m_webThree->ethereum(); } - dev::shh::WhisperHost* whisper() const { return m_webThree->whisper(); } + std::shared_ptr whisper() const { return m_webThree->whisper(); } QList const& owned() const { return m_myKeys; } diff --git a/libwebthree/WebThree.cpp b/libwebthree/WebThree.cpp index 55e82a36f..46725de1a 100644 --- a/libwebthree/WebThree.cpp +++ b/libwebthree/WebThree.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include using namespace std; using namespace dev; using namespace dev::p2p; @@ -45,8 +45,8 @@ WebThreeDirect::WebThreeDirect(std::string const& _clientVersion, std::string co if (_interfaces.count("eth")) m_ethereum.reset(new eth::Client(&m_net, _dbPath, _forceClean)); -// if (_interfaces.count("shh")) -// m_whisper = new eth::Whisper(m_net.get()); + if (_interfaces.count("shh")) + m_whisper = m_net.registerCapability(new WhisperHost); } WebThreeDirect::~WebThreeDirect() diff --git a/libwebthree/WebThree.h b/libwebthree/WebThree.h index 20789517d..3093c8106 100644 --- a/libwebthree/WebThree.h +++ b/libwebthree/WebThree.h @@ -74,7 +74,7 @@ public: // The mainline interfaces: eth::Client* ethereum() const { if (!m_ethereum) throw InterfaceNotSupported("eth"); return m_ethereum.get(); } - shh::WhisperHost* whisper() const { if (!m_whisper) throw InterfaceNotSupported("shh"); return m_whisper.get(); } + std::shared_ptr whisper() const { auto w = m_whisper.lock(); if (!w) throw InterfaceNotSupported("shh"); return w; } bzz::Interface* swarm() const { throw InterfaceNotSupported("bzz"); } // Misc stuff: @@ -118,7 +118,7 @@ private: std::string m_clientVersion; ///< Our end-application client's name/version. std::unique_ptr m_ethereum; ///< Main interface for Ethereum ("eth") protocol. - std::unique_ptr m_whisper; ///< Main interface for Whisper ("shh") protocol. + std::weak_ptr m_whisper; ///< Main interface for Whisper ("shh") protocol. p2p::Host m_net; ///< Should run in background and send us events when blocks found and allow us to send blocks as required. };