MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / getnetworkhashps

Function getnetworkhashps

src/rpc/mining.cpp:142–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142static RPCMethod getnetworkhashps()
143{
144 return RPCMethod{
145 "getnetworkhashps",
146 "Returns the estimated network hashes per second based on the last n blocks.\n"
147 "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
148 "Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
149 {
150 {"nblocks", RPCArg::Type::NUM, RPCArg::Default{120}, "The number of previous blocks to calculate estimate from, or -1 for blocks since last difficulty change."},
151 {"height", RPCArg::Type::NUM, RPCArg::Default{-1}, "To estimate at the time of the given height."},
152 },
153 RPCResult{
154 RPCResult::Type::NUM, "", "Hashes per second estimated"},
155 RPCExamples{
156 HelpExampleCli("getnetworkhashps", "")
157 + HelpExampleRpc("getnetworkhashps", "")
158 },
159 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
160{
161 ChainstateManager& chainman = EnsureAnyChainman(request.context);
162 LOCK(cs_main);
163 return GetNetworkHashPS(self.Arg<int>("nblocks"), self.Arg<int>("height"), chainman.ActiveChain());
164},
165 };
166}
167
168static bool GenerateBlock(ChainstateManager& chainman, CBlock&& block, uint64_t& max_tries, std::shared_ptr<const CBlock>& block_out, bool process_new_block)
169{

Callers 1

getmininginfoFunction · 0.85

Calls 3

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
GetNetworkHashPSFunction · 0.85

Tested by

no test coverage detected