From 6ff77181f26f61fdd23d7cc61f5cf072881bf9fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Mar 2017 18:23:20 +0200 Subject: [PATCH] Test --- src/main.cpp | 17 +++++++++++------ src/main.h | 2 +- src/miner.cpp | 12 +++++++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3f944a3bc..d258d185c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -721,7 +721,7 @@ int32_t komodo_validate_interest(const CTransaction& tx) } if ( (int64_t)tx.nLockTime < txheighttime-3600 ) { - if ( txheighttime > 1490159171 || (txheight == 0 && txheighttime >= 1490159171) ) // 246748 + if ( txheighttime > 1490159171 )//|| (txheight == 0 && txheighttime >= 1490159171) ) // 246748 { static uint32_t counter; if ( counter++ < 100 ) @@ -733,18 +733,20 @@ int32_t komodo_validate_interest(const CTransaction& tx) return(0); } -bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags) +bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags) { int32_t i; + if ( expiredp != 0 ) + *expiredp = 0; if (tx.nLockTime == 0) return true; if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD && (int64_t)tx.nLockTime < nBlockTime-3600 ) { - //if ( komodo_validate_interest(tx) < 0 ) - // return(false); if ( nBlockTime >= 1490159171 || nBlockHeight > 246748 ) // 246748 { fprintf(stderr,"[%d] IsFinalTx reject.%d locktime %u vs nBlockTime %u\n",(int32_t)(tx.nLockTime-nBlockTime),(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); + if ( expiredp != 0 ) + *expiredp = nBlockTime-3600; return(false); // need to prevent pastdating tx } else fprintf(stderr,"IsFinalTx grandfather.%d locktime %u vs nBlockTime %u\n",(int32_t)nBlockHeight,tx.nLockTime,(uint32_t)nBlockTime); } @@ -793,7 +795,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) ? chainActive.Tip()->GetMedianTimePast() : GetAdjustedTime(); - return IsFinalTx(tx, nBlockHeight, nBlockTime,flags); + return IsFinalTx(0,tx, nBlockHeight, nBlockTime,flags); } /** @@ -899,7 +901,10 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); if ( komodo_validate_interest(tx) < 0 ) + { + fprintf(stderr,"CheckTransaction komodo_validate_interest error\n"); return(false); + } n = tx.vin.size(); for (j=0; jGetMedianTimePast() : block.GetBlockTime(); - if (!IsFinalTx(tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { + if (!IsFinalTx(0,tx, nHeight, nLockTimeCutoff,0*STANDARD_LOCKTIME_VERIFY_FLAGS)) { return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal"); } } diff --git a/src/main.h b/src/main.h index 0a137188d..dcbd23632 100644 --- a/src/main.h +++ b/src/main.h @@ -351,7 +351,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason); * Check if transaction is final and can be included in a block with the * specified height and time. Consensus critical. */ -bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime, int flags); +bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime, int flags); /** * Check if transaction will be final in the next block to be created. diff --git a/src/miner.cpp b/src/miner.cpp index ab95c4aa6..cb6d4e23a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -183,7 +183,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) pblock->nTime = GetAdjustedTime(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); CCoinsViewCache view(pcoinsTip); - + uin32_t expired; + // Priority order to process transactions list vOrphan; // list memory doesn't move map > mapDependers; @@ -201,9 +202,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) ? nMedianTimePast : pblock->GetBlockTime(); - if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) + if (tx.IsCoinBase() || !IsFinalTx(&expired,tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS)) + { + if ( expired != 0 ) + { + fprintf(stderr,"expire from mempool tx.(%d %d) %.8f\n",tx.vins.size(),tx.vouts.size(),(double)tx.vouts[0].nValue/COIN); + } continue; - + } COrphan* porphan = NULL; double dPriority = 0; CAmount nTotalIn = 0;