This commit is contained in:
jl777
2017-03-22 18:23:20 +02:00
parent 3750f5afb8
commit 6ff77181f2
3 changed files with 21 additions and 10 deletions

View File

@@ -721,7 +721,7 @@ int32_t komodo_validate_interest(const CTransaction& tx)
} }
if ( (int64_t)tx.nLockTime < txheighttime-3600 ) 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; static uint32_t counter;
if ( counter++ < 100 ) if ( counter++ < 100 )
@@ -733,18 +733,20 @@ int32_t komodo_validate_interest(const CTransaction& tx)
return(0); 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; int32_t i;
if ( expiredp != 0 )
*expiredp = 0;
if (tx.nLockTime == 0) if (tx.nLockTime == 0)
return true; 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 ( 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 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); 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 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); } 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() ? chainActive.Tip()->GetMedianTimePast()
: GetAdjustedTime(); : 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 ) if ( *(int32_t *)&array[0] == 0 )
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array)));
if ( komodo_validate_interest(tx) < 0 ) if ( komodo_validate_interest(tx) < 0 )
{
fprintf(stderr,"CheckTransaction komodo_validate_interest error\n");
return(false); return(false);
}
n = tx.vin.size(); n = tx.vin.size();
for (j=0; j<n; j++) for (j=0; j<n; j++)
{ {
@@ -3320,7 +3325,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
? pindexPrev->GetMedianTimePast() ? pindexPrev->GetMedianTimePast()
: block.GetBlockTime(); : 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"); return state.DoS(10, error("%s: contains a non-final transaction", __func__), REJECT_INVALID, "bad-txns-nonfinal");
} }
} }

View File

@@ -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 * Check if transaction is final and can be included in a block with the
* specified height and time. Consensus critical. * 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. * Check if transaction will be final in the next block to be created.

View File

@@ -183,6 +183,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
pblock->nTime = GetAdjustedTime(); pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
CCoinsViewCache view(pcoinsTip); CCoinsViewCache view(pcoinsTip);
uin32_t expired;
// Priority order to process transactions // Priority order to process transactions
list<COrphan> vOrphan; // list memory doesn't move list<COrphan> vOrphan; // list memory doesn't move
@@ -201,9 +202,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
? nMedianTimePast ? nMedianTimePast
: pblock->GetBlockTime(); : 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; continue;
}
COrphan* porphan = NULL; COrphan* porphan = NULL;
double dPriority = 0; double dPriority = 0;
CAmount nTotalIn = 0; CAmount nTotalIn = 0;