|
|
|
@ -297,7 +297,7 @@ bool AddOrphanTx(const CDataStream& vMsg)
|
|
|
|
|
// at most 500 megabytes of orphans:
|
|
|
|
|
if (pvMsg->size() > 5000)
|
|
|
|
|
{
|
|
|
|
|
printf("ignoring large orphan tx (size: %"PRIszu", hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str());
|
|
|
|
|
printf("ignoring large orphan tx (size: %"PRIszu", hash: %s)\n", pvMsg->size(), hash.ToString().c_str());
|
|
|
|
|
delete pvMsg;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -306,7 +306,7 @@ bool AddOrphanTx(const CDataStream& vMsg)
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
|
|
|
|
mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg));
|
|
|
|
|
|
|
|
|
|
printf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().substr(0,10).c_str(),
|
|
|
|
|
printf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().c_str(),
|
|
|
|
|
mapOrphanTransactions.size());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -770,7 +770,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckIn
|
|
|
|
|
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
|
|
|
|
if (!tx.CheckInputs(state, view, true, SCRIPT_VERIFY_P2SH))
|
|
|
|
|
{
|
|
|
|
|
return error("CTxMemPool::accept() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str());
|
|
|
|
|
return error("CTxMemPool::accept() : ConnectInputs failed %s", hash.ToString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -792,7 +792,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckIn
|
|
|
|
|
SyncWithWallets(hash, tx, NULL, true);
|
|
|
|
|
|
|
|
|
|
printf("CTxMemPool::accept() : accepted %s (poolsz %"PRIszu")\n",
|
|
|
|
|
hash.ToString().substr(0,10).c_str(),
|
|
|
|
|
hash.ToString().c_str(),
|
|
|
|
|
mapTx.size());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -1198,11 +1198,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
|
|
|
|
|
uiInterface.NotifyBlocksChanged();
|
|
|
|
|
}
|
|
|
|
|
printf("InvalidChainFound: invalid block=%s height=%d work=%s date=%s\n",
|
|
|
|
|
BlockHashStr(pindexNew->GetBlockHash()).c_str(), pindexNew->nHeight,
|
|
|
|
|
pindexNew->GetBlockHash().ToString().c_str(), pindexNew->nHeight,
|
|
|
|
|
pindexNew->bnChainWork.ToString().c_str(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S",
|
|
|
|
|
pindexNew->GetBlockTime()).c_str());
|
|
|
|
|
printf("InvalidChainFound: current best=%s height=%d work=%s date=%s\n",
|
|
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(),
|
|
|
|
|
hashBestChain.ToString().c_str(), nBestHeight, bnBestChainWork.ToString().c_str(),
|
|
|
|
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str());
|
|
|
|
|
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");
|
|
|
|
@ -1366,7 +1366,7 @@ bool CTransaction::HaveInputs(CCoinsViewCache &inputs) const
|
|
|
|
|
bool CScriptCheck::operator()() const {
|
|
|
|
|
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
|
|
|
|
|
if (!VerifyScript(scriptSig, scriptPubKey, *ptxTo, nIn, nFlags, nHashType))
|
|
|
|
|
return error("CScriptCheck() : %s VerifySignature failed", ptxTo->GetHash().ToString().substr(0,10).c_str());
|
|
|
|
|
return error("CScriptCheck() : %s VerifySignature failed", ptxTo->GetHash().ToString().c_str());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1385,7 +1385,7 @@ bool CTransaction::CheckInputs(CValidationState &state, CCoinsViewCache &inputs,
|
|
|
|
|
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
|
|
|
|
// for an attacker to attempt to split the network.
|
|
|
|
|
if (!HaveInputs(inputs))
|
|
|
|
|
return state.Invalid(error("CheckInputs() : %s inputs unavailable", GetHash().ToString().substr(0,10).c_str()));
|
|
|
|
|
return state.Invalid(error("CheckInputs() : %s inputs unavailable", GetHash().ToString().c_str()));
|
|
|
|
|
|
|
|
|
|
// While checking, GetBestBlock() refers to the parent block.
|
|
|
|
|
// This is also true for mempool checks.
|
|
|
|
@ -1411,12 +1411,12 @@ bool CTransaction::CheckInputs(CValidationState &state, CCoinsViewCache &inputs,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (nValueIn < GetValueOut())
|
|
|
|
|
return state.DoS(100, error("CheckInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
|
|
|
|
|
return state.DoS(100, error("CheckInputs() : %s value in < value out", GetHash().ToString().c_str()));
|
|
|
|
|
|
|
|
|
|
// Tally transaction fees
|
|
|
|
|
int64 nTxFee = nValueIn - GetValueOut();
|
|
|
|
|
if (nTxFee < 0)
|
|
|
|
|
return state.DoS(100, error("CheckInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
|
|
|
|
|
return state.DoS(100, error("CheckInputs() : %s nTxFee < 0", GetHash().ToString().c_str()));
|
|
|
|
|
nFees += nTxFee;
|
|
|
|
|
if (!MoneyRange(nFees))
|
|
|
|
|
return state.DoS(100, error("CheckInputs() : nFees out of range"));
|
|
|
|
@ -1750,8 +1750,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|
|
|
|
reverse(vConnect.begin(), vConnect.end());
|
|
|
|
|
|
|
|
|
|
if (vDisconnect.size() > 0) {
|
|
|
|
|
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(), BlockHashStr(pfork->GetBlockHash()).c_str(), BlockHashStr(pindexNew->GetBlockHash()).c_str());
|
|
|
|
|
printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..\n", vDisconnect.size(), pfork->GetBlockHash().ToString().c_str());
|
|
|
|
|
printf("REORGANIZE: Connect %"PRIszu" blocks; ..%s\n", vConnect.size(), pindexNew->GetBlockHash().ToString().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disconnect shorter branch
|
|
|
|
@ -1762,7 +1762,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|
|
|
|
return state.Abort(_("Failed to read block"));
|
|
|
|
|
int64 nStart = GetTimeMicros();
|
|
|
|
|
if (!block.DisconnectBlock(state, pindex, view))
|
|
|
|
|
return error("SetBestBlock() : DisconnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str());
|
|
|
|
|
return error("SetBestBlock() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().c_str());
|
|
|
|
|
if (fBenchmark)
|
|
|
|
|
printf("- Disconnect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001);
|
|
|
|
|
|
|
|
|
@ -1786,7 +1786,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|
|
|
|
InvalidChainFound(pindexNew);
|
|
|
|
|
InvalidBlockFound(pindex);
|
|
|
|
|
}
|
|
|
|
|
return error("SetBestBlock() : ConnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str());
|
|
|
|
|
return error("SetBestBlock() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().c_str());
|
|
|
|
|
}
|
|
|
|
|
if (fBenchmark)
|
|
|
|
|
printf("- Connect: %.2fms\n", (GetTimeMicros() - nStart) * 0.001);
|
|
|
|
@ -1862,7 +1862,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|
|
|
|
nTimeBestReceived = GetTime();
|
|
|
|
|
nTransactionsUpdated++;
|
|
|
|
|
printf("SetBestChain: new best=%s height=%d work=%s tx=%lu date=%s progress=%f\n",
|
|
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx,
|
|
|
|
|
hashBestChain.ToString().c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx,
|
|
|
|
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str(),
|
|
|
|
|
Checkpoints::GuessVerificationProgress(pindexBest));
|
|
|
|
|
|
|
|
|
@ -1901,7 +1901,7 @@ bool CBlock::AddToBlockIndex(CValidationState &state, const CDiskBlockPos &pos)
|
|
|
|
|
// Check for duplicate
|
|
|
|
|
uint256 hash = GetHash();
|
|
|
|
|
if (mapBlockIndex.count(hash))
|
|
|
|
|
return state.Invalid(error("AddToBlockIndex() : %s already exists", BlockHashStr(hash).c_str()));
|
|
|
|
|
return state.Invalid(error("AddToBlockIndex() : %s already exists", hash.ToString().c_str()));
|
|
|
|
|
|
|
|
|
|
// Construct new block index object
|
|
|
|
|
CBlockIndex* pindexNew = new CBlockIndex(*this);
|
|
|
|
@ -2222,9 +2222,9 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
|
|
|
|
// Check for duplicate
|
|
|
|
|
uint256 hash = pblock->GetHash();
|
|
|
|
|
if (mapBlockIndex.count(hash))
|
|
|
|
|
return state.Invalid(error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, BlockHashStr(hash).c_str()));
|
|
|
|
|
return state.Invalid(error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().c_str()));
|
|
|
|
|
if (mapOrphanBlocks.count(hash))
|
|
|
|
|
return state.Invalid(error("ProcessBlock() : already have block (orphan) %s", BlockHashStr(hash).c_str()));
|
|
|
|
|
return state.Invalid(error("ProcessBlock() : already have block (orphan) %s", hash.ToString().c_str()));
|
|
|
|
|
|
|
|
|
|
// Preliminary checks
|
|
|
|
|
if (!pblock->CheckBlock(state))
|
|
|
|
@ -2253,7 +2253,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
|
|
|
|
// 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))
|
|
|
|
|
{
|
|
|
|
|
printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", BlockHashStr(pblock->hashPrevBlock).c_str());
|
|
|
|
|
printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().c_str());
|
|
|
|
|
|
|
|
|
|
// Accept orphans as long as there is a node to request its parents from
|
|
|
|
|
if (pfrom) {
|
|
|
|
@ -2589,7 +2589,7 @@ bool static LoadBlockIndexDB()
|
|
|
|
|
pindex = pindexPrev;
|
|
|
|
|
}
|
|
|
|
|
printf("LoadBlockIndexDB(): hashBestChain=%s height=%d date=%s\n",
|
|
|
|
|
BlockHashStr(hashBestChain).c_str(), nBestHeight,
|
|
|
|
|
hashBestChain.ToString().c_str(), nBestHeight,
|
|
|
|
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str());
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@ -3414,12 +3414,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|
|
|
|
if (pindex)
|
|
|
|
|
pindex = pindex->pnext;
|
|
|
|
|
int nLimit = 500;
|
|
|
|
|
printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), BlockHashStr(hashStop).c_str(), nLimit);
|
|
|
|
|
printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit);
|
|
|
|
|
for (; pindex; pindex = pindex->pnext)
|
|
|
|
|
{
|
|
|
|
|
if (pindex->GetBlockHash() == hashStop)
|
|
|
|
|
{
|
|
|
|
|
printf(" getblocks stopping at %d %s\n", pindex->nHeight, BlockHashStr(pindex->GetBlockHash()).c_str());
|
|
|
|
|
printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
|
|
|
@ -3427,7 +3427,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|
|
|
|
{
|
|
|
|
|
// When this block is requested, we'll send an inv that'll make them
|
|
|
|
|
// getblocks the next batch of inventory.
|
|
|
|
|
printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, BlockHashStr(pindex->GetBlockHash()).c_str());
|
|
|
|
|
printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
|
|
|
|
|
pfrom->hashContinue = pindex->GetBlockHash();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -3461,7 +3461,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|
|
|
|
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
|
|
|
|
vector<CBlock> vHeaders;
|
|
|
|
|
int nLimit = 2000;
|
|
|
|
|
printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), BlockHashStr(hashStop).c_str());
|
|
|
|
|
printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str());
|
|
|
|
|
for (; pindex; pindex = pindex->pnext)
|
|
|
|
|
{
|
|
|
|
|
vHeaders.push_back(pindex->GetBlockHeader());
|
|
|
|
@ -3510,7 +3510,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|
|
|
|
|
|
|
|
|
if (tx.AcceptToMemoryPool(stateDummy, true, true, &fMissingInputs2))
|
|
|
|
|
{
|
|
|
|
|
printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
|
|
|
|
|
printf(" accepted orphan tx %s\n", inv.hash.ToString().c_str());
|
|
|
|
|
RelayTransaction(tx, inv.hash, vMsg);
|
|
|
|
|
mapAlreadyAskedFor.erase(inv);
|
|
|
|
|
vWorkQueue.push_back(inv.hash);
|
|
|
|
@ -3520,7 +3520,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|
|
|
|
{
|
|
|
|
|
// invalid or too-little-fee orphan
|
|
|
|
|
vEraseQueue.push_back(inv.hash);
|
|
|
|
|
printf(" removed orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
|
|
|
|
|
printf(" removed orphan tx %s\n", inv.hash.ToString().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -3548,7 +3548,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|
|
|
|
CBlock block;
|
|
|
|
|
vRecv >> block;
|
|
|
|
|
|
|
|
|
|
printf("received block %s\n", BlockHashStr(block.GetHash()).c_str());
|
|
|
|
|
printf("received block %s\n", block.GetHash().ToString().c_str());
|
|
|
|
|
// block.print();
|
|
|
|
|
|
|
|
|
|
CInv inv(MSG_BLOCK, block.GetHash());
|
|
|
|
@ -4101,9 +4101,9 @@ public:
|
|
|
|
|
void print() const
|
|
|
|
|
{
|
|
|
|
|
printf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n",
|
|
|
|
|
ptx->GetHash().ToString().substr(0,10).c_str(), dPriority, dFeePerKb);
|
|
|
|
|
ptx->GetHash().ToString().c_str(), dPriority, dFeePerKb);
|
|
|
|
|
BOOST_FOREACH(uint256 hash, setDependsOn)
|
|
|
|
|
printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str());
|
|
|
|
|
printf(" setDependsOn %s\n", hash.ToString().c_str());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|