Merge pull request #362 from jl777/dev

Dev
This commit is contained in:
jl777
2017-03-24 04:26:18 +02:00
committed by GitHub
9 changed files with 138 additions and 52 deletions

View File

@@ -1246,7 +1246,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n", LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288)); MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
} }
if ( KOMODO_REWIND >= 0 ) if ( KOMODO_REWIND == 0 )
{ {
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
GetArg("-checkblocks", 288))) { GetArg("-checkblocks", 288))) {

View File

@@ -594,6 +594,27 @@ int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex)
return(0); return(0);
} }
CBlockIndex *komodo_chainactive(int32_t height)
{
if ( chainActive.Tip() != 0 )
{
if ( height <= chainActive.Tip()->nHeight )
return(chainActive[height]);
else fprintf(stderr,"komodo_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight);
}
//fprintf(stderr,"komodo_chainactive null chainActive.Tip() height %d\n",height);
return(0);
}
uint32_t komodo_heightstamp(int32_t height)
{
CBlockIndex *ptr;
if ( height > 0 && (ptr= komodo_chainactive(height)) != 0 )
return(ptr->nTime);
else fprintf(stderr,"komodo_heightstamp null ptr for block.%d\n",height);
return(0);
}
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
{ {
CBlock block; CBlock block;
@@ -618,11 +639,6 @@ void komodo_connectpindex(CBlockIndex *pindex)
komodo_connectblock(pindex,block); komodo_connectblock(pindex,block);
} }
CBlockIndex *komodo_chainactive(int32_t height)
{
return(chainActive[height]);
}
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height);
int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height); int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height);

View File

@@ -628,26 +628,32 @@ const char *banned_txids[] =
"a01671c8775328a41304e31a6693bbd35e9acbab28ab117f729eaba9cb769461", //235265 "a01671c8775328a41304e31a6693bbd35e9acbab28ab117f729eaba9cb769461", //235265
"2ef49d2d27946ad7c5d5e4ab5c089696762ff04e855f8ab48e83bdf0cc68726d", //235295 "2ef49d2d27946ad7c5d5e4ab5c089696762ff04e855f8ab48e83bdf0cc68726d", //235295
"c85dcffb16d5a45bd239021ad33443414d60224760f11d535ae2063e5709efee", //235296 "c85dcffb16d5a45bd239021ad33443414d60224760f11d535ae2063e5709efee", //235296
// all vouts banned
"305dc96d8bc23a69d3db955e03a6a87c1832673470c32fe25473a46cc473c7d1", //247204
}; };
void komodo_bannedset(uint256 *array,int32_t max) int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max)
{ {
int32_t i; int32_t i;
if ( sizeof(banned_txids)/sizeof(*banned_txids) > max )
{
fprintf(stderr,"komodo_bannedset: buffer too small %ld vs %d\n",sizeof(banned_txids)/sizeof(*banned_txids),max);
exit(-1);
}
for (i=0; i<sizeof(banned_txids)/sizeof(*banned_txids); i++) for (i=0; i<sizeof(banned_txids)/sizeof(*banned_txids); i++)
array[i] = uint256S(banned_txids[i]); array[i] = uint256S(banned_txids[i]);
if ( i != max ) *indallvoutsp = i-1;
printf("banned txid array error i.%d != max.%d\n",i,max); return(0);
//else printf("set %d banned txids\n",max);
} }
void komodo_passport_iteration(); void komodo_passport_iteration();
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
{ {
static uint256 array[15]; static uint256 array[64]; static int32_t numbanned,indallvouts;
int32_t i,j,k,n,ht,baseid,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; int32_t i,j,k,n,ht,baseid,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
if ( *(int32_t *)&array[0] == 0 ) if ( *(int32_t *)&array[0] == 0 )
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array)));
memset(baseids,0xff,sizeof(baseids)); memset(baseids,0xff,sizeof(baseids));
memset(values,0,sizeof(values)); memset(values,0,sizeof(values));
memset(srcvalues,0,sizeof(srcvalues)); memset(srcvalues,0,sizeof(srcvalues));
@@ -662,9 +668,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
n = block.vtx[i].vin.size(); n = block.vtx[i].vin.size();
for (j=0; j<n; j++) for (j=0; j<n; j++)
{ {
for (k=0; k<sizeof(array)/sizeof(*array); k++) for (k=0; k<numbanned; k++)
{ {
if ( block.vtx[i].vin[j].prevout.hash == array[k] && block.vtx[i].vin[j].prevout.n == 1 ) if ( block.vtx[i].vin[j].prevout.hash == array[k] && (block.vtx[i].vin[j].prevout.n == 1 || j >= indallvouts) )
{ {
printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j); printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j);
return(-1); return(-1);
@@ -714,13 +720,13 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
offset += komodo_scriptitemlen(&opretlen,&script[offset]); offset += komodo_scriptitemlen(&opretlen,&script[offset]);
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
extern int32_t KOMODO_REWIND; /*extern int32_t KOMODO_REWIND;
if ( KOMODO_REWIND < 0 ) if ( KOMODO_REWIND < 0 )
{ {
fprintf(stderr,">>>>>>> rewind.%d will pause here for a minute. issue command and stop\n",KOMODO_REWIND); fprintf(stderr,">>>>>>> rewind.%d will pause here for a minute. issue command and stop\n",KOMODO_REWIND);
sleep(60); sleep(60);
KOMODO_REWIND = 0; KOMODO_REWIND = 0;
} }*/
// 6a35506c65617365206d616b6520796f75722047697420636f6d6d6974206d65737361676573206d6f726520696e74657265737469 height.241778 checkdeposit n.4 [6a] [P] 80 vs 88 // 6a35506c65617365206d616b6520796f75722047697420636f6d6d6974206d65737361676573206d6f726520696e74657265737469 height.241778 checkdeposit n.4 [6a] [P] 80 vs 88
//for (i=0; i<opretlen; i++) //for (i=0; i<opretlen; i++)
// printf("%02x",script[i]); // printf("%02x",script[i]);

View File

@@ -24,7 +24,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp);
uint64_t komodo_paxtotal(); uint64_t komodo_paxtotal();
int32_t komodo_longestchain(); int32_t komodo_longestchain();
uint64_t komodo_maxallowed(int32_t baseid); uint64_t komodo_maxallowed(int32_t baseid);
void komodo_bannedset(uint256 *array,int32_t max); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
pthread_mutex_t komodo_mutex; pthread_mutex_t komodo_mutex;

View File

@@ -708,12 +708,39 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
return true; return true;
} }
int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,uint32_t txblocktime) uint32_t komodo_heightstamp(int32_t height);
int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32_t txheight,uint32_t prevblocktime)
{ {
int32_t i,txheight=0; uint32_t cmptime,txheighttime,tiptime=0,locktime; uint64_t value=0; int32_t i; uint32_t cmptime=0,tiptime=0,locktime=0; uint64_t value=0; CBlockIndex *tip=0;
if ( ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//1473793441 ) if ( KOMODO_REWIND == 0 && ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//1473793441 )
{ {
//locktime = komodo_interest_args(&prevblocktime,&txheight,&tiptime,&value,tx.GetHash(),0);
LOCK(cs_main);
CTransaction gettx; uint256 hashBlock; CBlockIndex *pindex,*previndex;
if ( GetTransaction(tx.GetHash(),gettx,hashBlock,true) )
{
if ( (pindex= mapBlockIndex[hashBlock]) != 0 )
{
txheight = pindex->nHeight;
if ( (previndex= pindex->pprev) != 0 )
prevblocktime = previndex->nTime;
}
}
if ( prevblocktime != 0 )
cmptime = prevblocktime + 600;
else
{
fprintf(stderr,"couldnt get cmptime for [%d] t%u\n",txheight,prevblocktime);
return(-1);
}
/* uint32_t prevblocktime=0,cmptime=0,txheighttime=0,tiptime=0,locktime=0;
prevblocktime = 0;
locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0); locktime = komodo_interest_args(&txheighttime,&txheight,&tiptime,&value,tx.GetHash(),0);
if ( (txheight= txheightarg) == 0 )
txheight = chainActive.Tip()->nHeight + 1;
if ( (prev= komodo_chainactive(txheight-1)) != 0 )
prevblocktime = prev->nTime;
if ( tiptime == 0 ) if ( tiptime == 0 )
tiptime = (int32_t)chainActive.Tip()->nTime; tiptime = (int32_t)chainActive.Tip()->nTime;
if ( txheighttime == 0 ) if ( txheighttime == 0 )
@@ -733,6 +760,10 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,uint3
cmptime = txblocktime; cmptime = txblocktime;
if ( tiptime != 0 && tiptime < cmptime ) if ( tiptime != 0 && tiptime < cmptime )
cmptime = tiptime; cmptime = tiptime;
if ( locktime != 0 && prevblocktime != 0 && prevblocktime < cmptime )
cmptime = prevblocktime;
if ( (prev= komodo_chainactive(txheight-1)) != 0 )
cmptime = prev->nTime + 600;
if ( cmptime >= 1490159171 - 24*3600 ) if ( cmptime >= 1490159171 - 24*3600 )
{ {
if ( cmptime != 0 && (int64_t)tx.nLockTime < cmptime-3600 ) if ( cmptime != 0 && (int64_t)tx.nLockTime < cmptime-3600 )
@@ -740,19 +771,44 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,uint3
if ( txheighttime > 1490159171 || (locktime == 0 && txheighttime >= 1490159171) ) // 246748 if ( txheighttime > 1490159171 || (locktime == 0 && txheighttime >= 1490159171) ) // 246748
{ {
if ( tx.nLockTime != 1477258935 ) if ( tx.nLockTime != 1477258935 )
{
fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u cmp.%u\n",txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime,cmptime); fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u cmp.%u\n",txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime,cmptime);
}
if ( expiredp != 0 ) if ( expiredp != 0 )
*expiredp = cmptime-3600; *expiredp = cmptime-3600;
return(-1); return(-1);
} else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime,cmptime); } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime,cmptime);
} }
} }
//fprintf(stderr,"validateinterest accept.%d tip.%d locktime %u/%u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,(int32_t)chainActive.Tip()->nHeight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime,txblocktime,cmptime); if ( (cmptime= prevblocktime) == 0 )
{
if ( (cmptime= komodo_heightstamp(txheight-1)) == 0 )
{
fprintf(stderr,"couldnt get prev.[%d] use tiptime.%u\n",txheight-1,cmptime);
return(-1);
}
}*/
if ( cmptime > 0 && txheight > 246748 )
{
if ( txheight < 247205 )
cmptime -= 600;
if ( (int64_t)tx.nLockTime < cmptime-3600 )
{
if ( tx.nLockTime != 1477258935 )
{
fprintf(stderr,"komodo_validate_interest reject.%d [%d] locktime %u tiptime.%u cmp.%u\n",txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,(uint32_t)(tip != 0 ? tip->nTime : 0),cmptime);
}
if ( expiredp != 0 )
*expiredp = cmptime-3600;
return(-1);
}
}
fprintf(stderr,"validateinterest accept.%d [%d] tip.%d locktime %u cmp.%u\n",(int32_t)txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(int32_t)(tip != 0 ? tip->nHeight : 0),(int32_t)tx.nLockTime,cmptime);
} }
return(0); return(0);
} }
bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags,int32_t interesttime) bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime,int flags,uint32_t prevblocktime)
{ {
int32_t i; int32_t i;
if ( expiredp != 0 ) if ( expiredp != 0 )
@@ -761,7 +817,7 @@ bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int6
return true; return true;
if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//&& nBlockTime >= 1473793441 ) //&& (int64_t)tx.nLockTime < nBlockTime-3600 if ( ASSETCHAINS_SYMBOL[0] == 0 && flags == STANDARD_LOCKTIME_VERIFY_FLAGS && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD )//&& nBlockTime >= 1473793441 ) //&& (int64_t)tx.nLockTime < nBlockTime-3600
{ {
if ( komodo_validate_interest(expiredp,tx,interesttime) < 0 ) //if ( nBlockTime >= 1490159171 ) // 246748 if ( komodo_validate_interest(expiredp,tx,nBlockHeight,prevblocktime < nBlockTime ? nBlockTime : prevblocktime) < 0 ) //if ( nBlockTime >= 1490159171 ) // 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);
return(false); // need to prevent pastdating tx return(false); // need to prevent pastdating tx
@@ -914,9 +970,9 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash::ProofVerifier& verifier) bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash::ProofVerifier& verifier)
{ {
static uint256 array[15]; int32_t j,k,n; static uint256 array[64]; static int32_t numbanned,indallvouts; int32_t j,k,n;
if ( *(int32_t *)&array[0] == 0 ) if ( *(int32_t *)&array[0] == 0 )
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); numbanned = komodo_bannedset(&indallvouts,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"); fprintf(stderr,"CheckTransaction komodo_validate_interest error\n");
@@ -925,13 +981,13 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash::
n = tx.vin.size(); n = tx.vin.size();
for (j=0; j<n; j++) for (j=0; j<n; j++)
{ {
for (k=0; k<sizeof(array)/sizeof(*array); k++) for (k=0; k<numbanned; k++)
{ {
if ( tx.vin[j].prevout.hash == array[k] && tx.vin[j].prevout.n == 1 ) if ( tx.vin[j].prevout.hash == array[k] && (tx.vin[j].prevout.n == 1 || j >= indallvouts) )
{ {
static uint32_t counter; static uint32_t counter;
if ( counter++ < 100 ) if ( counter++ < 100 )
printf("MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j); printf("MEMPOOL: banned tx.%d being used at ht.%d vout.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j);
return(false); return(false);
} }
} }
@@ -2829,27 +2885,22 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
if (!DisconnectTip(state)) if (!DisconnectTip(state))
return false; return false;
} }
/*if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) if ( KOMODO_REWIND != 0 )
{ {
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
while ( chainActive.Tip()->nHeight > KOMODO_REWIND ) while ( chainActive.Tip()->nHeight > KOMODO_REWIND )
{ {
if ( !DisconnectTip(state) ) if ( !DisconnectTip(state) )
{ {
//InvalidateBlock(state,chainActive.Tip()); InvalidateBlock(state,chainActive.Tip());
return false; return false;
} }
} }
fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND);
if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) sleep(60);
{ KOMODO_REWIND = 0;
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); return(true);
sleep(3); }
return(true);
}
pindexOldTip = chainActive.Tip();
pindexFork = chainActive.FindFork(pindexMostWork);
}*/
// Build list of new blocks to connect. // Build list of new blocks to connect.
std::vector<CBlockIndex*> vpindexToConnect; std::vector<CBlockIndex*> vpindexToConnect;
bool fContinue = true; bool fContinue = true;
@@ -3279,9 +3330,22 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
// Check transactions // Check transactions
BOOST_FOREACH(const CTransaction& tx, block.vtx) BOOST_FOREACH(const CTransaction& tx, block.vtx)
{ {
if ( komodo_validate_interest(0,tx,block.nTime) < 0 ) uint32_t prevtime = 0; CBlockIndex *ptr;
if ( height == chainActive.Tip()->nHeight+1 )
prevtime = chainActive.Tip()->nTime;
else if ( pindex != 0 )
{ {
//fprintf(stderr,"CheckBlock(%d:%d) %d, %u: komodo_validate_interest failure blocksize.%d\n",height,komodo_block2height((CBlock *)&block),pindex!=0?(int32_t)pindex->nHeight:0,pindex!=0?(int32_t)pindex->nTime:0,(int32_t)block.vtx.size()); if ( (ptr= pindex->pprev) != 0 )
prevtime = ptr->nTime;
}
if ( prevtime == 0 )
{
if ( height > 0 && (ptr= chainActive[height-1]) )
prevtime = ptr->nTime;
}
if ( komodo_validate_interest(0,tx,height,prevtime) < 0 )
{
//fprintf(stderr,"CheckBlock(%d:%d) %d, %u: komodo_validate_interest failure blocksize.%d tiptime.%u %u\n",height,komodo_block2height((CBlock *)&block),pindex!=0?(int32_t)pindex->nHeight:0,pindex!=0?(int32_t)pindex->nTime:0,(int32_t)block.vtx.size(),chainActive.Tip()->nTime,prevtime);
return error("CheckBlock: komodo_validate_interest failed"); return error("CheckBlock: komodo_validate_interest failed");
} }
if (!CheckTransaction(tx, state, verifier)) if (!CheckTransaction(tx, state, verifier))

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(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime, int flags,int32_t interesttime); bool IsFinalTx(uint32_t *expiredp,const CTransaction &tx, int nBlockHeight, int64_t nBlockTime, int flags,uint32_t prevblocktime);
/** /**
* 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

@@ -202,13 +202,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
? nMedianTimePast ? nMedianTimePast
: pblock->GetBlockTime(); : pblock->GetBlockTime();
if (tx.IsCoinBase() || !IsFinalTx(&expired,tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS,chainActive.Tip()->nTime+600)) if (tx.IsCoinBase() || !IsFinalTx(&expired,tx, nHeight, nLockTimeCutoff,STANDARD_LOCKTIME_VERIFY_FLAGS,chainActive.Tip()->nTime))
{ {
if ( expired != 0 ) if ( expired != 0 )
{ {
//fprintf(stderr,"expire from mempool tx. need to verify this works\n");//(%d %d) %.8f\n",tx.vins.size(),tx.vouts.size(),(double)tx.vouts[0].nValue/COIN); fprintf(stderr,"expire from mempool tx. need to verify this works\n");//(%d %d) %.8f\n",tx.vins.size(),tx.vouts.size(),(double)tx.vouts[0].nValue/COIN);
//list<CTransaction> removed; list<CTransaction> removed;
//mempool.remove(tx, removed, true); mempool.remove(tx, removed, true);
} }
continue; continue;
} //else fprintf(stderr,"coinbase or is finaltx (%d %u)\n",(int32_t)nHeight,(uint32_t)tx.nLockTime); } //else fprintf(stderr,"coinbase or is finaltx (%d %u)\n",(int32_t)nHeight,(uint32_t)tx.nLockTime);

View File

@@ -119,7 +119,7 @@ extern std::string NOTARY_PUBKEY;
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
{ {
//extern int32_t KOMODO_REWIND; extern int32_t KOMODO_REWIND;
bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66]; bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66];
arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33]; arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33];
@@ -156,7 +156,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
if ( UintToArith256(hash) > bnTarget ) if ( UintToArith256(hash) > bnTarget )
{ {
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 ) if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 )
//&& KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 //&& )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
{ {
int32_t i; int32_t i;
for (i=31; i>=0; i--) for (i=31; i>=0; i--)
@@ -171,7 +171,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
for (i=0; i<66; i++) for (i=0; i<66; i++)
printf("%d ",mids[i]); printf("%d ",mids[i]);
printf(" minerids from ht.%d\n",height); printf(" minerids from ht.%d\n",height);
if ( notaryid >= 0 || height > 225000 ) if ( KOMODO_REWIND == 0 && (notaryid >= 0 || height > 225000) )
return error("CheckProofOfWork(): hash doesn't match nBits"); return error("CheckProofOfWork(): hash doesn't match nBits");
} }
} }

View File

@@ -757,7 +757,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
{ {
//extern int32_t KOMODO_REWIND; extern int32_t KOMODO_REWIND;
{ {
LOCK(cs_wallet); LOCK(cs_wallet);
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) { for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
@@ -806,7 +806,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
extern char ASSETCHAINS_SYMBOL[16]; extern char ASSETCHAINS_SYMBOL[16];
fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize); fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
} }
//if ( KOMODO_REWIND == 0 ) if ( KOMODO_REWIND == 0 )
assert(nWitnessCacheSize > 0); assert(nWitnessCacheSize > 0);
//if (fFileBacked) { //if (fFileBacked) {
// CWalletDB walletdb(strWalletFile); // CWalletDB walletdb(strWalletFile);