mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge pull request #492 from gavinandresen/fasterinitialdownload
Skip verifying transaction signatures during initial block-chain download
This commit is contained in:
commit
ee1d6e4ed0
13
src/main.cpp
13
src/main.cpp
@ -810,6 +810,9 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo
|
|||||||
CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee)
|
CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee)
|
||||||
{
|
{
|
||||||
// Take over previous transactions' spent pointers
|
// Take over previous transactions' spent pointers
|
||||||
|
// fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain
|
||||||
|
// fMiner is true when called from the internal bitcoin miner
|
||||||
|
// ... both are false when called from CTransaction::AcceptToMemoryPool
|
||||||
if (!IsCoinBase())
|
if (!IsCoinBase())
|
||||||
{
|
{
|
||||||
int64 nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
@ -863,9 +866,13 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo
|
|||||||
if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile)
|
if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile)
|
||||||
return DoS(10, error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight));
|
return DoS(10, error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight));
|
||||||
|
|
||||||
// Verify signature
|
// Skip ECDSA signature verification when connecting blocks (fBlock=true) during initial download
|
||||||
if (!VerifySignature(txPrev, *this, i))
|
// (before the last blockchain checkpoint). This is safe because block merkle hashes are
|
||||||
return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
|
// still computed and checked, and any change will be caught at the next checkpoint.
|
||||||
|
if (!(fBlock && IsInitialBlockDownload()))
|
||||||
|
// Verify signature
|
||||||
|
if (!VerifySignature(txPrev, *this, i))
|
||||||
|
return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
|
||||||
|
|
||||||
// Check for conflicts (double-spend)
|
// Check for conflicts (double-spend)
|
||||||
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
||||||
|
Loading…
Reference in New Issue
Block a user