From 94c37803df44d686bada6c66a8447f02948dc1ea Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 16 Dec 2018 21:06:17 +0800 Subject: [PATCH] Final fix for mempool --- src/cc/CCinclude.h | 6 +++--- src/main.cpp | 12 ++++++------ src/main.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 83c85e551..28091b957 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h all of the above are the standard bitcoin vout types and there should be plenty of materials about it Encrypted by a verified device what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. - + but it gets more interesting each CC script has an evalcode this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different @@ -73,7 +73,7 @@ struct CC_utxo // these are the parameters stored after Verus crypto-condition vouts. new versions may change // the format -struct CC_meta +struct CC_meta { std::vector version; uint8_t evalCode; @@ -110,7 +110,7 @@ int32_t komodo_nextheight(); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); -bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL); +bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); //uint64_t myGettxout(uint256 hash,int32_t n); bool myIsutxo_spentinmempool(uint256 txid,int32_t vout); bool mytxid_inmempool(uint256 txid); diff --git a/src/main.cpp b/src/main.cpp index b0513f25f..d44207db9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1597,7 +1597,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF } -bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel) +bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel, bool fSkipExpiry) { AssertLockHeld(cs_main); if (pfMissingInputs) @@ -1634,7 +1634,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // DoS level set to 10 to be more forgiving. // Check transaction contextually against the set of consensus rules which apply in the next block to be mined. - if (!ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) + if (!fSkipExpiry && !ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } @@ -1973,14 +1973,14 @@ bool GetAddressUnspent(uint160 addressHash, int type, else return(coins.vout[n].nValue); }*/ -bool myAddtomempool(CTransaction &tx, CValidationState *pstate) +bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry) { CValidationState state; if (!pstate) pstate = &state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) - return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees)); + return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees, -1, fSkipExpiry)); else return(true); } @@ -4686,7 +4686,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { const CTransaction &tx = e.GetTx(); const uint256 &hash = tx.GetHash(); - if ( tx.vjoinsplit.empty() || tx.vShieldedSpend.empty()) { + if ( tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { transactionsToRemove.push_back(tx); tmpmempool.addUnchecked(hash,e,true); } @@ -4708,7 +4708,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) continue; Tx = tx; - if ( myAddtomempool(Tx, &state) == false ) // happens with out of order tx in block on resync + if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync { //LogPrintf("Rejected by mempool, reason: .%s.\n", state.GetRejectReason().c_str()); // take advantage of other checks, but if we were only rejected because it is a valid staking diff --git a/src/main.h b/src/main.h index 00055b39c..fdd9fcae8 100644 --- a/src/main.h +++ b/src/main.h @@ -274,7 +274,7 @@ void PruneAndFlush(); /** (try to) add transaction to memory pool **/ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, - bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1); + bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1, bool fSkipExpiry=false); struct CNodeStateStats {