trb

trb
Log | Files | Refs

commit 270ca19d951c21bb17c0c904f56011b53b1b5b78
parent d33580fcb63ff7a64263e7277d1b0894c51a9068
Author: Shinoa-Fores <btcinfo@sdf.org>
Date:   Wed, 13 Jan 2021 17:25:50 -0500

asciilifeform_and_now_we_have_eatblock.vpatch

Diffstat:
Mbitcoin/src/bitcoinrpc.cpp | 23+++++++++++++++++++++++
Mbitcoin/src/init.cpp | 2++
Mbitcoin/src/util.cpp | 1+
Mbitcoin/src/util.h | 1+
4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/bitcoin/src/bitcoinrpc.cpp b/bitcoin/src/bitcoinrpc.cpp @@ -1817,6 +1817,28 @@ Value dumpblock(const Array& params, bool fHelp) } +Value eatblock(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 1) + throw runtime_error( + "eatblock <filename>\n" + "Load a candidate for the next block directly from <filename>."); + + if (!fCanEat) + throw runtime_error( + "'eatblock' is only permitted if bitcoind was started with -caneat flag!"); + + // path to load block from + string filename = params[0].get_str(); + + printf("Attempting to create block #%d from file %s\n", nBestHeight + 1, filename.c_str()); + CAutoFile filein = fopen(filename.c_str(), "rb"); + CBlock block; + filein >> block; + return ProcessBlock(NULL, &block); // note that 'true' even if it was rejected (bastard, etc) +} // ... but will return 'false' if we already have the block. + + // // Call Table @@ -1865,6 +1887,7 @@ pair<string, rpcfn_type> pCallTable[] = make_pair("getmemorypool", &getmemorypool), make_pair("listsinceblock", &listsinceblock), make_pair("dumpblock", &dumpblock), + make_pair("eatblock", &eatblock), }; map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0])); diff --git a/bitcoin/src/init.cpp b/bitcoin/src/init.cpp @@ -174,6 +174,7 @@ bool AppInit2(int argc, char* argv[]) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + " -testnet \t\t " + _("Use the test network\n") + " -debug \t\t " + _("Output extra debugging information\n") + + " -caneat \t\t " + _("Permit the use of 'eatblock'\n") + " -logtimestamps \t " + _("Prepend debug output with timestamp\n") + " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") + " -rpcuser=<user> \t " + _("Username for JSON-RPC connections\n") + @@ -196,6 +197,7 @@ bool AppInit2(int argc, char* argv[]) fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); fDaemon = GetBoolArg("-daemon"); + fCanEat = GetBoolArg("-caneat"); if (fDaemon) fServer = true; diff --git a/bitcoin/src/util.cpp b/bitcoin/src/util.cpp @@ -20,6 +20,7 @@ map<string, vector<string> > mapMultiArgs; bool fDebug = false; bool fPrintToConsole = false; bool fPrintToDebugger = false; +bool fCanEat = false; char pszSetDataDir[MAX_PATH] = ""; bool fRequestShutdown = false; bool fShutdown = false; diff --git a/bitcoin/src/util.h b/bitcoin/src/util.h @@ -110,6 +110,7 @@ extern std::map<std::string, std::vector<std::string> > mapMultiArgs; extern bool fDebug; extern bool fPrintToConsole; extern bool fPrintToDebugger; +extern bool fCanEat; extern char pszSetDataDir[MAX_PATH]; extern bool fRequestShutdown; extern bool fShutdown;