| 850 | } |
| 851 | |
| 852 | Value getblockfailures(const Array& params, bool fHelp) { |
| 853 | if (fHelp || params.size() != 1) { |
| 854 | throw runtime_error( |
| 855 | "getblockfailures \"block height\"\n" |
| 856 | "\nGet log failures by block height.\n" |
| 857 | "\nArguments:\n" |
| 858 | "1.\"block height\" (numberic, required)\n" |
| 859 | "\nResult:\n" |
| 860 | "\nExamples:\n" + |
| 861 | HelpExampleCli("getblockfailures", "100") + |
| 862 | "\nAs json rpc call\n" + |
| 863 | HelpExampleRpc("getblockfailures", "100")); |
| 864 | } |
| 865 | |
| 866 | int height = params[0].get_int(); |
| 867 | if (height < 0 || height > chainActive.Height()) |
| 868 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range."); |
| 869 | |
| 870 | auto dbIt = MakeDbIterator(pCdMan->pLogCache->executeFailCache); |
| 871 | |
| 872 | Object obj; |
| 873 | Array failures; |
| 874 | Object failure; |
| 875 | |
| 876 | for (dbIt->First(); dbIt->IsValid(); dbIt->Next()) { |
| 877 | |
| 878 | //CCompositeKVCache<dbk::TX_EXECUTE_FAIL, string, std::pair<uint8_t, string> > executeFailCache; |
| 879 | failure.push_back(Pair("txid", dbIt->GetKey().second.GetHex())); |
| 880 | failure.push_back(Pair("error_code", dbIt->GetValue().first)); |
| 881 | failure.push_back(Pair("error_message", dbIt->GetValue().second)); |
| 882 | |
| 883 | failures.push_back(failure); |
| 884 | } |
| 885 | |
| 886 | obj.push_back(Pair("block_height", height)); |
| 887 | obj.push_back(Pair("failures", failures)); |
| 888 | |
| 889 | return obj; |
| 890 | } |
nothing calls this directly
no test coverage detected