Browse Source

ethstubserver listening and peerCount

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
1bb1b0fa4d
  1. 31
      libethrpc/EthStubServer.cpp
  2. 3
      libwebthree/WebThree.h

31
libethrpc/EthStubServer.cpp

@ -102,7 +102,7 @@ EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDi
dev::eth::Interface* EthStubServer::client() const dev::eth::Interface* EthStubServer::client() const
{ {
return &(*m_web3.ethereum()); return m_web3.ethereum();
} }
std::string EthStubServer::balanceAt(const string &address, const int& block) std::string EthStubServer::balanceAt(const string &address, const int& block)
@ -220,10 +220,9 @@ std::string EthStubServer::gasPrice()
return toJS(10 * dev::eth::szabo); return toJS(10 * dev::eth::szabo);
} }
//TODO
bool EthStubServer::listening() bool EthStubServer::listening()
{ {
return /*client() ? client()->haveNetwork() :*/ false; return m_web3.isNetworkStarted();
} }
bool EthStubServer::mining() bool EthStubServer::mining()
@ -312,11 +311,9 @@ int EthStubServer::number()
return client() ? client()->number() + 1 : 0; return client() ? client()->number() + 1 : 0;
} }
//TODO!
int EthStubServer::peerCount() int EthStubServer::peerCount()
{ {
return /*client() ? (unsigned)client()->peerCount() :*/ 0; return m_web3.peerCount();
//return m_web3.peerCount();
} }
std::string EthStubServer::secretToAddress(const string &s) std::string EthStubServer::secretToAddress(const string &s)
@ -332,14 +329,11 @@ bool EthStubServer::setCoinbase(const std::string &address)
bool EthStubServer::setListening(const bool &listening) bool EthStubServer::setListening(const bool &listening)
{ {
if (!client()) if (listening)
return Json::nullValue; m_web3.startNetwork();
/* if (l)
client()->startNetwork();
else else
client()->stopNetwork();*/ m_web3.stopNetwork();
return false; return true;
} }
bool EthStubServer::setMining(const bool &mining) bool EthStubServer::setMining(const bool &mining)
@ -458,15 +452,4 @@ bool EthStubServer::killWatch(const int& id)
return true; return true;
} }
#endif #endif

3
libwebthree/WebThree.h

@ -119,6 +119,9 @@ public:
/// Stop the network subsystem. /// Stop the network subsystem.
void stopNetwork() { m_net.stop(); } void stopNetwork() { m_net.stop(); }
/// Is network working? there may not be any peers yet.
bool isNetworkStarted() { return m_net.isStarted(); }
private: private:
std::string m_clientVersion; ///< Our end-application client's name/version. std::string m_clientVersion; ///< Our end-application client's name/version.

Loading…
Cancel
Save