|
|
@ -1168,11 +1168,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew) |
|
|
|
uiInterface.NotifyBlocksChanged(); |
|
|
|
uiInterface.NotifyBlocksChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
printf("InvalidChainFound: invalid block=%s height=%d work=%s date=%s\n", |
|
|
|
printf("InvalidChainFound: invalid block=%s height=%d work=%s date=%s\n", |
|
|
|
pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, |
|
|
|
BlockHashStr(pindexNew->GetBlockHash()).c_str(), pindexNew->nHeight, |
|
|
|
pindexNew->bnChainWork.ToString().c_str(), DateTimeStrFormat("%x %H:%M:%S", |
|
|
|
pindexNew->bnChainWork.ToString().c_str(), DateTimeStrFormat("%x %H:%M:%S", |
|
|
|
pindexNew->GetBlockTime()).c_str()); |
|
|
|
pindexNew->GetBlockTime()).c_str()); |
|
|
|
printf("InvalidChainFound: current best=%s height=%d work=%s date=%s\n", |
|
|
|
printf("InvalidChainFound: current best=%s height=%d work=%s date=%s\n", |
|
|
|
hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6) |
|
|
|
if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6) |
|
|
|
printf("InvalidChainFound: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); |
|
|
|
printf("InvalidChainFound: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); |
|
|
@ -1693,8 +1693,8 @@ bool SetBestChain(CBlockIndex* pindexNew) |
|
|
|
reverse(vConnect.begin(), vConnect.end()); |
|
|
|
reverse(vConnect.begin(), vConnect.end()); |
|
|
|
|
|
|
|
|
|
|
|
if (vDisconnect.size() > 0) { |
|
|
|
if (vDisconnect.size() > 0) { |
|
|
|
printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); |
|
|
|
printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), BlockHashStr(pfork->GetBlockHash()).c_str(), BlockHashStr(pindexBest->GetBlockHash()).c_str()); |
|
|
|
printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); |
|
|
|
printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), BlockHashStr(pfork->GetBlockHash()).c_str(), BlockHashStr(pindexNew->GetBlockHash()).c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Disconnect shorter branch
|
|
|
|
// Disconnect shorter branch
|
|
|
@ -1705,7 +1705,7 @@ bool SetBestChain(CBlockIndex* pindexNew) |
|
|
|
return error("SetBestBlock() : ReadFromDisk for disconnect failed"); |
|
|
|
return error("SetBestBlock() : ReadFromDisk for disconnect failed"); |
|
|
|
CCoinsViewCache viewTemp(view, true); |
|
|
|
CCoinsViewCache viewTemp(view, true); |
|
|
|
if (!block.DisconnectBlock(pindex, viewTemp)) |
|
|
|
if (!block.DisconnectBlock(pindex, viewTemp)) |
|
|
|
return error("SetBestBlock() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str()); |
|
|
|
return error("SetBestBlock() : DisconnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str()); |
|
|
|
if (!viewTemp.Flush()) |
|
|
|
if (!viewTemp.Flush()) |
|
|
|
return error("SetBestBlock() : Cache flush failed after disconnect"); |
|
|
|
return error("SetBestBlock() : Cache flush failed after disconnect"); |
|
|
|
|
|
|
|
|
|
|
@ -1725,7 +1725,7 @@ bool SetBestChain(CBlockIndex* pindexNew) |
|
|
|
if (!block.ConnectBlock(pindex, viewTemp)) { |
|
|
|
if (!block.ConnectBlock(pindex, viewTemp)) { |
|
|
|
InvalidChainFound(pindexNew); |
|
|
|
InvalidChainFound(pindexNew); |
|
|
|
InvalidBlockFound(pindex); |
|
|
|
InvalidBlockFound(pindex); |
|
|
|
return error("SetBestBlock() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str()); |
|
|
|
return error("SetBestBlock() : ConnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!viewTemp.Flush()) |
|
|
|
if (!viewTemp.Flush()) |
|
|
|
return error("SetBestBlock() : Cache flush failed after connect"); |
|
|
|
return error("SetBestBlock() : Cache flush failed after connect"); |
|
|
@ -1781,7 +1781,7 @@ bool SetBestChain(CBlockIndex* pindexNew) |
|
|
|
nTimeBestReceived = GetTime(); |
|
|
|
nTimeBestReceived = GetTime(); |
|
|
|
nTransactionsUpdated++; |
|
|
|
nTransactionsUpdated++; |
|
|
|
printf("SetBestChain: new best=%s height=%d work=%s tx=%lu date=%s\n", |
|
|
|
printf("SetBestChain: new best=%s height=%d work=%s tx=%lu date=%s\n", |
|
|
|
hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx, |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx, |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Check the version of the last 100 blocks to see if we need to upgrade:
|
|
|
|
// Check the version of the last 100 blocks to see if we need to upgrade:
|
|
|
@ -1819,7 +1819,7 @@ bool CBlock::AddToBlockIndex(const CDiskBlockPos &pos) |
|
|
|
// Check for duplicate
|
|
|
|
// Check for duplicate
|
|
|
|
uint256 hash = GetHash(); |
|
|
|
uint256 hash = GetHash(); |
|
|
|
if (mapBlockIndex.count(hash)) |
|
|
|
if (mapBlockIndex.count(hash)) |
|
|
|
return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str()); |
|
|
|
return error("AddToBlockIndex() : %s already exists", BlockHashStr(hash).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Construct new block index object
|
|
|
|
// Construct new block index object
|
|
|
|
CBlockIndex* pindexNew = new CBlockIndex(*this); |
|
|
|
CBlockIndex* pindexNew = new CBlockIndex(*this); |
|
|
@ -2111,9 +2111,9 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp) |
|
|
|
// Check for duplicate
|
|
|
|
// Check for duplicate
|
|
|
|
uint256 hash = pblock->GetHash(); |
|
|
|
uint256 hash = pblock->GetHash(); |
|
|
|
if (mapBlockIndex.count(hash)) |
|
|
|
if (mapBlockIndex.count(hash)) |
|
|
|
return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str()); |
|
|
|
return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, BlockHashStr(hash).c_str()); |
|
|
|
if (mapOrphanBlocks.count(hash)) |
|
|
|
if (mapOrphanBlocks.count(hash)) |
|
|
|
return error("ProcessBlock() : already have block (orphan) %s", hash.ToString().substr(0,20).c_str()); |
|
|
|
return error("ProcessBlock() : already have block (orphan) %s", BlockHashStr(hash).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Preliminary checks
|
|
|
|
// Preliminary checks
|
|
|
|
if (!pblock->CheckBlock()) |
|
|
|
if (!pblock->CheckBlock()) |
|
|
@ -2146,7 +2146,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp) |
|
|
|
// If we don't already have its previous block, shunt it off to holding area until we get it
|
|
|
|
// If we don't already have its previous block, shunt it off to holding area until we get it
|
|
|
|
if (pblock->hashPrevBlock != 0 && !mapBlockIndex.count(pblock->hashPrevBlock)) |
|
|
|
if (pblock->hashPrevBlock != 0 && !mapBlockIndex.count(pblock->hashPrevBlock)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str()); |
|
|
|
printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", BlockHashStr(pblock->hashPrevBlock).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Accept orphans as long as there is a node to request its parents from
|
|
|
|
// Accept orphans as long as there is a node to request its parents from
|
|
|
|
if (pfrom) { |
|
|
|
if (pfrom) { |
|
|
@ -2318,7 +2318,7 @@ bool static LoadBlockIndexDB() |
|
|
|
pindex = pindexPrev; |
|
|
|
pindex = pindexPrev; |
|
|
|
} |
|
|
|
} |
|
|
|
printf("LoadBlockIndex(): hashBestChain=%s height=%d date=%s\n", |
|
|
|
printf("LoadBlockIndex(): hashBestChain=%s height=%d date=%s\n", |
|
|
|
hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, |
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
// Load bnBestInvalidWork, OK if it doesn't exist
|
|
|
|
// Load bnBestInvalidWork, OK if it doesn't exist
|
|
|
@ -3028,12 +3028,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
if (pindex) |
|
|
|
if (pindex) |
|
|
|
pindex = pindex->pnext; |
|
|
|
pindex = pindex->pnext; |
|
|
|
int nLimit = 500; |
|
|
|
int nLimit = 500; |
|
|
|
printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit); |
|
|
|
printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), BlockHashStr(hashStop).c_str(), nLimit); |
|
|
|
for (; pindex; pindex = pindex->pnext) |
|
|
|
for (; pindex; pindex = pindex->pnext) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pindex->GetBlockHash() == hashStop) |
|
|
|
if (pindex->GetBlockHash() == hashStop) |
|
|
|
{ |
|
|
|
{ |
|
|
|
printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); |
|
|
|
printf(" getblocks stopping at %d %s\n", pindex->nHeight, BlockHashStr(pindex->GetBlockHash()).c_str()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); |
|
|
|
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); |
|
|
@ -3041,7 +3041,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// When this block is requested, we'll send an inv that'll make them
|
|
|
|
// When this block is requested, we'll send an inv that'll make them
|
|
|
|
// getblocks the next batch of inventory.
|
|
|
|
// getblocks the next batch of inventory.
|
|
|
|
printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); |
|
|
|
printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, BlockHashStr(pindex->GetBlockHash()).c_str()); |
|
|
|
pfrom->hashContinue = pindex->GetBlockHash(); |
|
|
|
pfrom->hashContinue = pindex->GetBlockHash(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -3074,7 +3074,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
|
|
|
|
|
|
|
|
vector<CBlock> vHeaders; |
|
|
|
vector<CBlock> vHeaders; |
|
|
|
int nLimit = 2000; |
|
|
|
int nLimit = 2000; |
|
|
|
printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str()); |
|
|
|
printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), BlockHashStr(hashStop).c_str()); |
|
|
|
for (; pindex; pindex = pindex->pnext) |
|
|
|
for (; pindex; pindex = pindex->pnext) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vHeaders.push_back(pindex->GetBlockHeader()); |
|
|
|
vHeaders.push_back(pindex->GetBlockHeader()); |
|
|
@ -3158,7 +3158,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
CBlock block; |
|
|
|
CBlock block; |
|
|
|
vRecv >> block; |
|
|
|
vRecv >> block; |
|
|
|
|
|
|
|
|
|
|
|
printf("received block %s\n", block.GetHash().ToString().substr(0,20).c_str()); |
|
|
|
printf("received block %s\n", BlockHashStr(block.GetHash()).c_str()); |
|
|
|
// block.print();
|
|
|
|
// block.print();
|
|
|
|
|
|
|
|
|
|
|
|
CInv inv(MSG_BLOCK, block.GetHash()); |
|
|
|
CInv inv(MSG_BLOCK, block.GetHash()); |
|
|
|