Skip to content

Commit

Permalink
Add optional 3rd parameter to 'dumpbootstrap' to specify the first bl…
Browse files Browse the repository at this point in the history
…ock number to dump.
  • Loading branch information
dooglus committed Jun 26, 2015
1 parent a27cc13 commit f3a357e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,21 @@ Value getbestblockhash(const Array& params, bool fHelp)

Value dumpbootstrap(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 2)
if (fHelp || params.size() < 2 || params.size() > 3)
throw runtime_error(
"dumpbootstrap \"destination\" \"blocks\"\n"
"\nCreates a bootstrap format block dump of the blockchain in destination, which can be a directory or a path with filename, up to the given block number.");
"dumpbootstrap <destination> <endblock> [startblock=0]\n"
"Creates a bootstrap format block dump of the blockchain in destination, which can be a directory or a path with filename, up to the given endblock number.\n"
"Optional <startblock> is the first block number to dump.");

string strDest = params[0].get_str();
int nBlocks = params[1].get_int();
if (nBlocks < 0 || nBlocks > nBestHeight)
throw runtime_error("Block number out of range.");
int nEndBlock = params[1].get_int();
if (nEndBlock < 0 || nEndBlock > nBestHeight)
throw runtime_error("End block number out of range.");
int nStartBlock = 0;
if (params.size() > 2)
nStartBlock = params[2].get_int();
if (nStartBlock < 0 || nStartBlock > nEndBlock)
throw runtime_error("Start block number out of range.");

boost::filesystem::path pathDest(strDest);
if (boost::filesystem::is_directory(pathDest))
Expand All @@ -198,7 +204,7 @@ Value dumpbootstrap(const Array& params, bool fHelp)
if (!fileout)
throw JSONRPCError(RPC_MISC_ERROR, "Error: Could not open bootstrap file for writing.");

for (int nHeight = 0; nHeight <= nBlocks; nHeight++)
for (int nHeight = nStartBlock; nHeight <= nEndBlock; nHeight++)
{
CBlock block;
CBlockIndex* pblockindex = FindBlockByHeight(nHeight);
Expand Down Expand Up @@ -325,7 +331,7 @@ Value getblockbynumber(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
"getblockbynumber <number> [txinfo]\n"
"getblockbynumber <number> [txinfo] [raw]\n"
"txinfo optional to print more detailed tx info\n"
"raw optional to return block as raw hex data\n"
"Returns details of a block with given block-number.");
Expand Down
1 change: 1 addition & 0 deletions src/rpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "importprivkey", 2 },
{ "importwallet", 2 },
{ "dumpbootstrap", 1 },
{ "dumpbootstrap", 2 },
{ "validateoutputs", 0 },
};

Expand Down

0 comments on commit f3a357e

Please sign in to comment.