main: add block timestamp index
This commit is contained in:
committed by
Braydon Fuller
parent
24deb4efc1
commit
935ca8f832
@@ -275,6 +275,38 @@ UniValue getrawmempool(const UniValue& params, bool fHelp)
|
||||
return mempoolToJSON(fVerbose);
|
||||
}
|
||||
|
||||
UniValue getblockhashes(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 2)
|
||||
throw runtime_error(
|
||||
"getblockhashes timestamp\n"
|
||||
"\nReturns array of hashes of blocks within the timestamp range provided.\n"
|
||||
"\nArguments:\n"
|
||||
"1. high (numeric, required) The newer block timestamp\n"
|
||||
"2. low (numeric, required) The older block timestamp\n"
|
||||
"\nResult:\n"
|
||||
"["
|
||||
" \"hash\" (string) The block hash\n"
|
||||
"]"
|
||||
"\nExamples:\n"
|
||||
);
|
||||
|
||||
unsigned int high = params[0].get_int();
|
||||
unsigned int low = params[1].get_int();
|
||||
std::vector<uint256> blockHashes;
|
||||
|
||||
if (!GetTimestampIndex(high, low, blockHashes)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for block hashes");
|
||||
}
|
||||
|
||||
UniValue result(UniValue::VARR);
|
||||
for (std::vector<uint256>::const_iterator it=blockHashes.begin(); it!=blockHashes.end(); it++) {
|
||||
result.push_back(it->GetHex());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UniValue getblockhash(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
|
||||
Reference in New Issue
Block a user