|
|
@ -455,8 +455,7 @@ bool CTransaction::AreInputsStandard(CCoinsViewCache& mapInputs) const |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
unsigned int |
|
|
|
unsigned int CTransaction::GetLegacySigOpCount() const |
|
|
|
CTransaction::GetLegacySigOpCount() const |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned int nSigOps = 0; |
|
|
|
unsigned int nSigOps = 0; |
|
|
|
BOOST_FOREACH(const CTxIn& txin, vin) |
|
|
|
BOOST_FOREACH(const CTxIn& txin, vin) |
|
|
@ -1177,7 +1176,7 @@ int GetNumBlocksOfPeers() |
|
|
|
|
|
|
|
|
|
|
|
bool IsInitialBlockDownload() |
|
|
|
bool IsInitialBlockDownload() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate() || fReindex || fImporting) |
|
|
|
if (pindexBest == NULL || fImporting || fReindex || nBestHeight < Checkpoints::GetTotalBlocksEstimate()) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
static int64 nLastUpdate; |
|
|
|
static int64 nLastUpdate; |
|
|
|
static CBlockIndex* pindexLastBest; |
|
|
|
static CBlockIndex* pindexLastBest; |
|
|
@ -1634,7 +1633,6 @@ bool CBlock::ConnectBlock(CValidationState &state, CBlockIndex* pindex, CCoinsVi |
|
|
|
vPos.reserve(vtx.size()); |
|
|
|
vPos.reserve(vtx.size()); |
|
|
|
for (unsigned int i=0; i<vtx.size(); i++) |
|
|
|
for (unsigned int i=0; i<vtx.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
const CTransaction &tx = vtx[i]; |
|
|
|
const CTransaction &tx = vtx[i]; |
|
|
|
|
|
|
|
|
|
|
|
nInputs += tx.vin.size(); |
|
|
|
nInputs += tx.vin.size(); |
|
|
@ -1798,7 +1796,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) |
|
|
|
return error("SetBestBlock() : ConnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str()); |
|
|
|
return error("SetBestBlock() : ConnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (fBenchmark) |
|
|
|
if (fBenchmark) |
|
|
|
printf("- Connect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001); |
|
|
|
printf("- Connect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001); |
|
|
|
|
|
|
|
|
|
|
|
// Queue memory transactions to delete
|
|
|
|
// Queue memory transactions to delete
|
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) |
|
|
|
BOOST_FOREACH(const CTransaction& tx, block.vtx) |
|
|
@ -2449,7 +2447,7 @@ bool AbortNode(const std::string &strMessage) { |
|
|
|
fRequestShutdown = true; |
|
|
|
fRequestShutdown = true; |
|
|
|
strMiscWarning = strMessage; |
|
|
|
strMiscWarning = strMessage; |
|
|
|
printf("*** %s\n", strMessage.c_str()); |
|
|
|
printf("*** %s\n", strMessage.c_str()); |
|
|
|
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MODAL); |
|
|
|
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_ERROR); |
|
|
|
StartShutdown(); |
|
|
|
StartShutdown(); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -2496,7 +2494,7 @@ FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly) { |
|
|
|
return OpenDiskFile(pos, "blk", fReadOnly); |
|
|
|
return OpenDiskFile(pos, "blk", fReadOnly); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FILE *OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly) { |
|
|
|
FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly) { |
|
|
|
return OpenDiskFile(pos, "rev", fReadOnly); |
|
|
|
return OpenDiskFile(pos, "rev", fReadOnly); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2548,9 +2546,9 @@ bool static LoadBlockIndexDB() |
|
|
|
|
|
|
|
|
|
|
|
// Load block file info
|
|
|
|
// Load block file info
|
|
|
|
pblocktree->ReadLastBlockFile(nLastBlockFile); |
|
|
|
pblocktree->ReadLastBlockFile(nLastBlockFile); |
|
|
|
printf("LoadBlockIndex(): last block file = %i\n", nLastBlockFile); |
|
|
|
printf("LoadBlockIndexDB(): last block file = %i\n", nLastBlockFile); |
|
|
|
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile)) |
|
|
|
if (pblocktree->ReadBlockFileInfo(nLastBlockFile, infoLastBlockFile)) |
|
|
|
printf("LoadBlockIndex(): last block file: %s\n", infoLastBlockFile.ToString().c_str()); |
|
|
|
printf("LoadBlockIndexDB(): last block file info: %s\n", infoLastBlockFile.ToString().c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Load bnBestInvalidWork, OK if it doesn't exist
|
|
|
|
// Load bnBestInvalidWork, OK if it doesn't exist
|
|
|
|
pblocktree->ReadBestInvalidWork(bnBestInvalidWork); |
|
|
|
pblocktree->ReadBestInvalidWork(bnBestInvalidWork); |
|
|
@ -2562,7 +2560,7 @@ bool static LoadBlockIndexDB() |
|
|
|
|
|
|
|
|
|
|
|
// Check whether we have a transaction index
|
|
|
|
// Check whether we have a transaction index
|
|
|
|
pblocktree->ReadFlag("txindex", fTxIndex); |
|
|
|
pblocktree->ReadFlag("txindex", fTxIndex); |
|
|
|
printf("LoadBlockIndex(): transaction index %s\n", fTxIndex ? "enabled" : "disabled"); |
|
|
|
printf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled"); |
|
|
|
|
|
|
|
|
|
|
|
// Load hashBestChain pointer to end of best chain
|
|
|
|
// Load hashBestChain pointer to end of best chain
|
|
|
|
pindexBest = pcoinsTip->GetBestBlock(); |
|
|
|
pindexBest = pcoinsTip->GetBestBlock(); |
|
|
@ -2579,7 +2577,7 @@ bool static LoadBlockIndexDB() |
|
|
|
pindexPrev->pnext = pindex; |
|
|
|
pindexPrev->pnext = pindex; |
|
|
|
pindex = pindexPrev; |
|
|
|
pindex = pindexPrev; |
|
|
|
} |
|
|
|
} |
|
|
|
printf("LoadBlockIndex(): hashBestChain=%s height=%d date=%s\n", |
|
|
|
printf("LoadBlockIndexDB(): hashBestChain=%s height=%d date=%s\n", |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, |
|
|
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
|
|
|
|
|
|
|
@ -2748,7 +2746,7 @@ bool InitBlockIndex() { |
|
|
|
CDiskBlockPos blockPos; |
|
|
|
CDiskBlockPos blockPos; |
|
|
|
CValidationState state; |
|
|
|
CValidationState state; |
|
|
|
if (!FindBlockPos(state, blockPos, nBlockSize+8, 0, block.nTime)) |
|
|
|
if (!FindBlockPos(state, blockPos, nBlockSize+8, 0, block.nTime)) |
|
|
|
return error("AcceptBlock() : FindBlockPos failed"); |
|
|
|
return error("LoadBlockIndex() : FindBlockPos failed"); |
|
|
|
if (!block.WriteToDisk(blockPos)) |
|
|
|
if (!block.WriteToDisk(blockPos)) |
|
|
|
return error("LoadBlockIndex() : writing genesis block to disk failed"); |
|
|
|
return error("LoadBlockIndex() : writing genesis block to disk failed"); |
|
|
|
if (!block.AddToBlockIndex(state, blockPos)) |
|
|
|
if (!block.AddToBlockIndex(state, blockPos)) |
|
|
@ -3310,7 +3308,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CMerkleBlock merkleBlock(block, *pfrom->pfilter); |
|
|
|
CMerkleBlock merkleBlock(block, *pfrom->pfilter); |
|
|
|
pfrom->PushMessage("merkleblock", merkleBlock); |
|
|
|
pfrom->PushMessage("merkleblock", merkleBlock); |
|
|
|
// CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
|
|
|
|
// CMerkleBlock just contains hashes, so also push any transactions in the block the client did not see
|
|
|
|
// This avoids hurting performance by pointlessly requiring a round-trip
|
|
|
|
// This avoids hurting performance by pointlessly requiring a round-trip
|
|
|
|
// Note that there is currently no way for a node to request any single transactions we didnt send here -
|
|
|
|
// Note that there is currently no way for a node to request any single transactions we didnt send here -
|
|
|
|
// they must either disconnect and retry or request the full block.
|
|
|
|
// they must either disconnect and retry or request the full block.
|
|
|
|