changeset 23695:c5dff189e132

Skip Xpress Validation if the thinblock previous block hash does not match the chaintip hash
author Peter Tschipper <peter.tschipper@gmailcom>
date Mon, 22 Feb 2016 07:55:57 -0800
parents a78a20598afd
children c06f2cd01482
files src/main.cpp
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.cpp	Fri Jan 15 21:37:25 2016 -0800
+++ b/src/main.cpp	Mon Feb 22 07:55:57 2016 -0800
@@ -5080,6 +5080,9 @@
 
         int missingCount = 0;
         int unnecessaryCount = 0;
+        // Xpress Validation - only perform xval if the chaintip matches the last blockhash in the thinblock
+        bool fXVal = (thinBlock.header.hashPrevBlock == chainActive.Tip()->GetBlockHash()) ? true : false;
+
         // Look for each transaction in our various pools and buffers.
         // With xThinBlocks the vTxHashes contains only the first 8 bytes of the tx hash.
         BOOST_FOREACH(uint64_t &cheapHash, thinBlock.vTxHashes) 
@@ -5094,7 +5097,7 @@
                 if (inMemPool && inMissingTx)
                     unnecessaryCount++;
 
-                if (inMemPool)
+                if (inMemPool && fXVal)
                     setPreVerifiedTxHash.insert(hash);
                 else if (inMissingTx)
                     tx = thinBlock.mapMissingTx[hash];
@@ -5162,9 +5165,12 @@
         pfrom->thinBlock.hashPrevBlock = thinBlock.header.hashPrevBlock;
         pfrom->thinBlockHashes = thinBlock.vTxHashes;
 
+        LOCK(cs_main);
         int missingCount = 0;
         int unnecessaryCount = 0;
-        LOCK(cs_main);
+        // Xpress Validation - only perform xval if the chaintip matches the last blockhash in the thinblock
+        bool fXVal = (thinBlock.header.hashPrevBlock == chainActive.Tip()->GetBlockHash()) ? true : false;
+
         // Look for each transaction in our various pools and buffers.
         BOOST_FOREACH(const uint256 &hash, thinBlock.vTxHashes) 
         {
@@ -5176,7 +5182,7 @@
                 if (inMemPool && inMissingTx)
                     unnecessaryCount++;
 
-                if (inMemPool)
+                if (inMemPool && fXVal)
                     setPreVerifiedTxHash.insert(hash);
                 else if (inMissingTx)
                     tx = thinBlock.mapMissingTx[hash];