Prevent miner from mining too big a block in txvalue

This commit is contained in:
jl777
2019-03-02 03:27:25 -11:00
parent de704db25f
commit e8afffb17b

View File

@@ -173,7 +173,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
}
} else pk = _pk;
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
//fprintf(stderr,"create new block\n");
@@ -221,6 +221,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
uint256 cbHash;
voutsum = GetBlockSubsidy(nHeight,consensusParams) + nFees;
CBlockIndex* pindexPrev = 0;
{
ENTER_CRITICAL_SECTION(cs_main);
@@ -270,7 +271,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
vecPriority.reserve(mempool.mapTx.size() + 1);
// now add transactions from the mem pool
int32_t Notarisations = 0;
int32_t Notarisations = 0; uint64_t txvalue;
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
mi != mempool.mapTx.end(); ++mi)
{
@@ -285,7 +286,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
//fprintf(stderr,"coinbase.%d finaltx.%d expired.%d\n",tx.IsCoinBase(),IsFinalTx(tx, nHeight, nLockTimeCutoff),IsExpiredTx(tx, nHeight));
continue;
}
txvalue = tx.GetValueOut();
if ( KOMODO_VALUETOOBIG(txvalue) != 0 )
continue;
if ( KOMODO_VALUETOOBIG(txvalue + voutsum) != 0 )
continue;
voutsum += txvalue;
if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 )
{
//fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime);
@@ -621,7 +627,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
txNew.vout.resize(1);
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
//fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN);
txNew.nExpiryHeight = 0;
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());