New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add capability to generate seed blocks over RPC #325
Changes from 2 commits
50ce158
4b472fd
55fa47a
d3308bf
45da456
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,65 @@ bool BalanceToJSON(const std::string& address, uint32_t property, Object& balanc | |
} | ||
} | ||
|
||
// generate a list of seed blocks based on the data in LevelDB | ||
Value omni_getseedblocks(const Array& params, bool fHelp) | ||
{ | ||
if (fHelp || params.size() < 2 || params.size() > 3) | ||
throw runtime_error( | ||
"omni_getseedblocks startblock endblock\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be: |
||
"\nReturns a list of blocks containing Omni transactions for use in seed block filtering.\n" | ||
"\nWARNING: The Exodus crowdsale is not stored in LevelDB, thus this is currently only safe to use to generate seed blocks after block 255365" | ||
"\nArguments:\n" | ||
"1. startblock (number, required) the first block to look for Omni transactions (inclusive)\n" | ||
"2. endblock (number, required) the last block to look for Omni transactions (inclusive)\n" | ||
"3. stringify (bool, optional) whether to output one continuous string of seed blocks for easier inclusion in seedblocks.cpp\n" | ||
"\nResult:\n" | ||
"[ (array of JSON objects)\n" | ||
" {\n" | ||
" \"seedblock\" : blockheight, (number) the blockheight of the seed block\n" | ||
" },\n" | ||
" ...\n" | ||
"]\n" | ||
"\nExamples:\n" | ||
+ HelpExampleCli("omni_getseedblocks", "290000 300000") | ||
+ HelpExampleRpc("omni_getseedblocks", "290000, 300000") | ||
); | ||
|
||
int startHeight = params[0].get_int(); | ||
int endHeight = params[1].get_int(); | ||
bool overrideOutput = false; | ||
if (params.size() > 2) overrideOutput = params[2].get_bool(); | ||
|
||
RequireHeightInChain(startHeight); | ||
RequireHeightInChain(endHeight); | ||
|
||
std::set<int> setSeedBlocks = p_txlistdb->GetSeedBlocks(startHeight, endHeight); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we do it here, or in the function itself ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do it here, to guard the pointer |
||
|
||
Array response; | ||
std::string stringifiedOutput; | ||
|
||
for (std::set<int>::const_iterator it = setSeedBlocks.begin(); it != setSeedBlocks.end(); ++it) { | ||
if (!overrideOutput) { | ||
Object seedBlockObj; | ||
seedBlockObj.push_back(Pair("seedblock", *it)); | ||
response.push_back(seedBlockObj); | ||
} else { | ||
stringifiedOutput += strprintf("%d, ", *it); | ||
} | ||
} | ||
|
||
if (!overrideOutput) { | ||
return response; | ||
} else { | ||
Object stringifiedResponse; | ||
if (stringifiedOutput.size()>2) { // remove trailing ", " | ||
stringifiedOutput.erase(stringifiedOutput.size()-2); | ||
} | ||
stringifiedResponse.push_back(Pair("seedblocks", stringifiedOutput)); | ||
return stringifiedResponse; | ||
} | ||
} | ||
|
||
// obtain the payload for a transaction | ||
Value omni_getpayload(const Array& params, bool fHelp) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,9 @@ static const CRPCConvertParam vRPCConvertParams[] = | |
{ "omni_listblocktransactions", 0 }, | ||
{ "omni_getorderbook", 0 }, | ||
{ "omni_getorderbook", 1 }, | ||
{ "omni_getseedblocks", 0 }, | ||
{ "omni_getseedblocks", 1 }, | ||
{ "omni_getseedblocks", 2 }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is no longer needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks dude, just testing without these and then will push the change :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, think I misread your comment - thought you meant all three weren't required (which I wanted to test because I didn't think it would work). Now rereading I realize you meant just the last line hehe - all sorted. |
||
|
||
/* Omni Core - transaction calls */ | ||
{ "omni_send", 2 }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
boost::token_compress_on
.