From 380b93d7681d15506a50df44dcc7ec7caa73915b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:10:28 +0200 Subject: [PATCH 1/3] Test --- src/main.cpp | 24 ++++++++++++++++++++++-- src/miner.cpp | 4 ++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5b4142369..d85543682 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2407,6 +2407,26 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin for (unsigned int i = 0; i < block.vtx.size(); i++) { const CTransaction &tx = block.vtx[i]; + uint32_t prevtime = 0; CBlockIndex *ptr; + if ( (ptr= pindex->pprev) != 0 ) + prevtime = ptr->nTime; + /*if ( chainActive.Tip() != 0 && height == chainActive.Tip()->nHeight+1 ) + prevtime = chainActive.Tip()->nTime; + else if ( pindex != 0 ) + { + if ( (ptr= pindex->pprev) != 0 ) + prevtime = ptr->nTime; + } + if ( prevtime == 0 ) + { + if ( height > 0 && (ptr= chainActive[height-1]) != 0 ) + prevtime = ptr->nTime; + }*/ + if ( komodo_validate_interest(0,tx,pindex->nHeight,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 state.DoS(10, error("ConnectBlock(): validate interest failed"),REJECT_INVALID, "bad-apr-calc"); + } nInputs += tx.vin.size(); nSigOps += GetLegacySigOpCount(tx); @@ -3341,7 +3361,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat // Check transactions BOOST_FOREACH(const CTransaction& tx, block.vtx) { - uint32_t prevtime = 0; CBlockIndex *ptr; + /*uint32_t prevtime = 0; CBlockIndex *ptr; if ( chainActive.Tip() != 0 && height == chainActive.Tip()->nHeight+1 ) prevtime = chainActive.Tip()->nTime; else if ( pindex != 0 ) @@ -3358,7 +3378,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat { //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"); - } + }*/ if (!CheckTransaction(tx, state, verifier)) return error("CheckBlock(): CheckTransaction failed"); } diff --git a/src/miner.cpp b/src/miner.cpp index 91318d641..c0ab729d4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -207,8 +207,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) 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); - list removed; - mempool.remove(tx, removed, true); + //list removed; + //mempool.remove(tx, removed, true); } continue; } //else fprintf(stderr,"coinbase or is finaltx (%d %u)\n",(int32_t)nHeight,(uint32_t)tx.nLockTime); From ac6feaa8a089953709c533d64eae62a49eb7ddc4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:10:51 +0200 Subject: [PATCH 2/3] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d85543682..d150f6488 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -738,7 +738,7 @@ int32_t komodo_validate_interest(uint32_t *expiredp,const CTransaction& tx,int32 { prevblocktime = chainActive.Tip()->nTime; fprintf(stderr,"couldnt get prevblocktime for [%d] tiptime.%u\n",txheight,prevblocktime); - //return(-1); + return(-1); } } } From 464fe491ab89e88bac1b5af4e6c8ac3fa4b2abd6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 24 Mar 2017 07:23:55 +0200 Subject: [PATCH 3/3] Test --- src/komodo_gateway.h | 4 ++-- src/main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6bf946d6e..ef1937d0c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -643,7 +643,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) for (i=0; i= indallvouts) ) + if ( block.vtx[i].vin[j].prevout.hash == array[k] && (block.vtx[i].vin[j].prevout.n == 1 || k >= indallvouts) ) { printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j); return(-1); diff --git a/src/main.cpp b/src/main.cpp index d150f6488..c0d4ec9a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -994,7 +994,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,libzcash:: { for (k=0; k= indallvouts) ) + if ( tx.vin[j].prevout.hash == array[k] && (tx.vin[j].prevout.n == 1 || k >= indallvouts) ) { static uint32_t counter; if ( counter++ < 100 )