| 99 | } |
| 100 | |
| 101 | static RPCHelpMan getnetworkhashps() |
| 102 | { |
| 103 | return RPCHelpMan{"getnetworkhashps", |
| 104 | "\nReturns the estimated network hashes per second based on the last n blocks.\n" |
| 105 | "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n" |
| 106 | "Pass in [height] to estimate the network speed at the time when a certain block was found.\n", |
| 107 | { |
| 108 | {"nblocks", RPCArg::Type::NUM, RPCArg::Default{120}, "The number of blocks, or -1 for blocks since last difficulty change."}, |
| 109 | {"height", RPCArg::Type::NUM, RPCArg::Default{-1}, "To estimate at the time of the given height."}, |
| 110 | }, |
| 111 | RPCResult{ |
| 112 | RPCResult::Type::NUM, "", "Hashes per second estimated"}, |
| 113 | RPCExamples{ |
| 114 | HelpExampleCli("getnetworkhashps", "") |
| 115 | + HelpExampleRpc("getnetworkhashps", "") |
| 116 | }, |
| 117 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 118 | { |
| 119 | ChainstateManager& chainman = EnsureAnyChainman(request.context); |
| 120 | LOCK(cs_main); |
| 121 | return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1, chainman.ActiveChain()); |
| 122 | }, |
| 123 | }; |
| 124 | } |
| 125 | |
| 126 | static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t& max_tries, unsigned int& extra_nonce, uint256& block_hash) |
| 127 | { |
no test coverage detected