Kagome
Polkadot Runtime Engine in C++17
health.cpp
Go to the documentation of this file.
1 
7 
10 
12 
13  Health::Health(std::shared_ptr<SystemApi> api) : api_(std::move(api)) {
14  BOOST_ASSERT(api_ != nullptr);
15  }
16 
17  outcome::result<void> Health::init(
18  const jsonrpc::Request::Parameters &params) {
19  if (!params.empty()) {
20  throw jsonrpc::InvalidParametersFault("Method should not have params");
21  }
22  return outcome::success();
23  }
24 
25  outcome::result<jsonrpc::Value::Struct> Health::execute() {
26  jsonrpc::Value::Struct data;
27 
28  // isSyncing - Whether the node is syncing.
29  data["isSyncing"] =
30  makeValue(api_->getBabe()->getCurrentState()
32 
33  // peers - Number of connected peers
34  data["peers"] = makeValue(
35  static_cast<uint64_t>(api_->getPeerManager()->activePeersNumber()));
36 
37  // shouldHavePeers - Should this node have any peers.
38  // Might be false for local chains or when running without discovery.
39  data["shouldHavePeers"] =
40  makeValue(api_->getConfig()->chainType() != "Development");
41 
42  return data;
43  }
44 
45 } // namespace kagome::api::system::request
STL namespace.
outcome::result< void > init(const jsonrpc::Request::Parameters &params)
Definition: health.cpp:17
std::shared_ptr< SystemApi > api_
Definition: health.hpp:39
outcome::result< jsonrpc::Value::Struct > execute()
Definition: health.cpp:25
jsonrpc::Value makeValue(const uint32_t &)