Fabcoin Core  0.16.2
P2P Digital Currency
Net.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
24 #include <libwebthree/WebThree.h>
25 #include <libdevcore/CommonJS.h>
26 #include <libethcore/Common.h>
27 #include "Net.h"
28 
29 using namespace dev;
30 using namespace dev::rpc;
31 
32 Net::Net(NetworkFace& _network): m_network(_network) {}
33 
34 std::string Net::net_version()
35 {
36  return toString(m_network.networkId());
37 }
38 
39 std::string Net::net_peerCount()
40 {
41  return toJS(m_network.peerCount());
42 }
43 
45 {
46  return m_network.isNetworkStarted();
47 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
virtual u256 networkId() const =0
Get network id.
virtual bool net_listening() override
Definition: Net.cpp:44
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Definition: CommonData.cpp:141
virtual std::string net_version() override
Definition: Net.cpp:34
Net(NetworkFace &_network)
Definition: Net.cpp:32
std::string toJS(FixedHash< S > const &_h)
Definition: CommonJS.h:34
NetworkFace & m_network
Definition: Net.h:48
virtual bool isNetworkStarted() const =0
Is network working? there may not be any peers yet.
virtual std::string net_peerCount() override
Definition: Net.cpp:39
virtual size_t peerCount() const =0
Same as peers().size(), but more efficient.