Skip to content

Commit

Permalink
Merge pull request bitcoin#5385
Browse files Browse the repository at this point in the history
57be955 Remove -printblock, -printblocktree, and -printblockindex (Pieter Wuille)
  • Loading branch information
laanwj committed Nov 27, 2014
2 parents faa1623 + 57be955 commit 2adce1f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 101 deletions.
30 changes: 0 additions & 30 deletions src/init.cpp
Expand Up @@ -330,8 +330,6 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n";
if (GetBoolArg("-help-debug", false))
{
strUsage += " -printblock=<hash> " + _("Print block on startup, if found in block index") + "\n";
strUsage += " -printblocktree " + strprintf(_("Print block tree on startup (default: %u)"), 0) + "\n";
strUsage += " -printpriority " + strprintf(_("Log transaction priority and fee per kB when mining blocks (default: %u)"), 0) + "\n";
strUsage += " -privdb " + strprintf(_("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)"), 1) + "\n";
strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + "\n";
Expand Down Expand Up @@ -1048,34 +1046,6 @@ bool AppInit2(boost::thread_group& threadGroup)
}
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart);

if (GetBoolArg("-printblockindex", false) || GetBoolArg("-printblocktree", false))
{
PrintBlockTree();
return false;
}

if (mapArgs.count("-printblock"))
{
string strMatch = mapArgs["-printblock"];
int nFound = 0;
for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{
uint256 hash = (*mi).first;
if (boost::algorithm::starts_with(hash.ToString(), strMatch))
{
CBlockIndex* pindex = (*mi).second;
CBlock block;
ReadBlockFromDisk(block, pindex);
block.BuildMerkleTree();
LogPrintf("%s\n", block.ToString());
nFound++;
}
}
if (nFound == 0)
LogPrintf("No blocks matching %s were found\n", strMatch);
return false;
}

boost::filesystem::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
CAutoFile est_filein(fopen(est_path.string().c_str(), "rb"), SER_DISK, CLIENT_VERSION);
// Allowed to fail as this file IS missing on first startup.
Expand Down
69 changes: 0 additions & 69 deletions src/main.cpp
Expand Up @@ -3113,75 +3113,6 @@ bool InitBlockIndex() {



void PrintBlockTree()
{
AssertLockHeld(cs_main);
// pre-compute tree structure
map<CBlockIndex*, vector<CBlockIndex*> > mapNext;
for (BlockMap::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
{
CBlockIndex* pindex = (*mi).second;
mapNext[pindex->pprev].push_back(pindex);
// test
//while (rand() % 3 == 0)
// mapNext[pindex->pprev].push_back(pindex);
}

vector<pair<int, CBlockIndex*> > vStack;
vStack.push_back(make_pair(0, chainActive.Genesis()));

int nPrevCol = 0;
while (!vStack.empty())
{
int nCol = vStack.back().first;
CBlockIndex* pindex = vStack.back().second;
vStack.pop_back();

// print split or gap
if (nCol > nPrevCol)
{
for (int i = 0; i < nCol-1; i++)
LogPrintf("| ");
LogPrintf("|\\\n");
}
else if (nCol < nPrevCol)
{
for (int i = 0; i < nCol; i++)
LogPrintf("| ");
LogPrintf("|\n");
}
nPrevCol = nCol;

// print columns
for (int i = 0; i < nCol; i++)
LogPrintf("| ");

// print item
CBlock block;
ReadBlockFromDisk(block, pindex);
LogPrintf("%d (blk%05u.dat:0x%x) %s tx %u\n",
pindex->nHeight,
pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos,
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()),
block.vtx.size());

// put the main time-chain first
vector<CBlockIndex*>& vNext = mapNext[pindex];
for (unsigned int i = 0; i < vNext.size(); i++)
{
if (chainActive.Next(vNext[i]))
{
swap(vNext[0], vNext[i]);
break;
}
}

// iterate children
for (unsigned int i = 0; i < vNext.size(); i++)
vStack.push_back(make_pair(nCol+i, vNext[i]));
}
}

bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
{
// Map of disk positions for blocks with unknown parent (only used for reindex)
Expand Down
2 changes: 0 additions & 2 deletions src/main.h
Expand Up @@ -177,8 +177,6 @@ bool InitBlockIndex();
bool LoadBlockIndex();
/** Unload database information */
void UnloadBlockIndex();
/** Print the loaded block tree */
void PrintBlockTree();
/** Process protocol messages received from a given node */
bool ProcessMessages(CNode* pfrom);
/** Send queued protocol messages to be sent to a give node */
Expand Down

0 comments on commit 2adce1f

Please sign in to comment.