From 3bf6b75986fe58c37f35828260eb434b6a2dca74 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sat, 12 Jan 2019 00:02:06 +0800 Subject: [PATCH] fix miner.cpp --- src/miner.cpp | 130 +------------------------------------------------- 1 file changed, 2 insertions(+), 128 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 56f348f6a..fb61e96ed 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -213,13 +213,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // we will attempt to spend any cheats we see CTransaction cheatTx; boost::optional cheatSpend; -<<<<<<< HEAD - uint256 cbHash; - -======= - uint256 cbHash; ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed + uint256 cbHash; + CBlockIndex* pindexPrev = 0; { ENTER_CRITICAL_SECTION(cs_main); @@ -289,7 +285,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool fNotarisation = false; if (tx.IsCoinImport()) { -<<<<<<< HEAD CAmount nValueIn = GetCoinImportValue(tx); // burn amount nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16. @@ -298,12 +293,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, if ( komodo_is_notarytx(tx) == 1 ) fToCryptoAddress = true; -======= - CAmount nValueIn = GetCoinImportValue(tx); - nTotalIn += nValueIn; - dPriority += (double)nValueIn * 1000; // flat multiplier - } else { ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -342,7 +331,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, int nConf = nHeight - coins->nHeight; -<<<<<<< HEAD // This is to test is a tx is a notarisation and assign it max priotity. if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) { @@ -358,10 +346,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, } if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 ) fNotarisation = true; -======= - dPriority += (double)nValueIn * nConf; } ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed nTotalIn += tx.GetShieldedValueIn(); } @@ -376,22 +361,10 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); -<<<<<<< HEAD if (fNotarisation) { dPriority = 1e16; //fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str()); -======= - if (porphan) - { - porphan->dPriority = dPriority; - porphan->feeRate = feeRate; ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed } - else - vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx()))); - } - -<<<<<<< HEAD if (porphan) { porphan->dPriority = dPriority; @@ -494,101 +467,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, nBlockSigOps += nTxSigOps; nFees += nTxFees; -======= - // Collect transactions into block - uint64_t nBlockSize = 1000; - uint64_t nBlockTx = 0; - int64_t interest; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); - - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - - while (!vecPriority.empty()) - { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - CFeeRate feeRate = vecPriority.front().get<1>(); - const CTransaction& tx = *(vecPriority.front().get<2>()); - - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx - { - //fprintf(stderr,"nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); - continue; - } - - // Legacy limits on sigOps: - unsigned int nTxSigOps = GetLegacySigOpCount(tx); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); - double dPriorityDelta = 0; - CAmount nFeeDelta = 0; - mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); - if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - { - //fprintf(stderr,"fee rate skip\n"); - continue; - } - // Prioritise by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - - if (!view.HaveInputs(tx)) - { - //fprintf(stderr,"dont have inputs\n"); - continue; - } - CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut(); - - nTxSigOps += GetP2SHSigOpCount(tx, view); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1) - { - //fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS); - continue; - } - // Note that flags: we don't want to set mempool/IsStandard() - // policy here, but we still have to ensure that the block we - // create only contains transactions that are valid in new blocks. - CValidationState state; - PrecomputedTransactionData txdata(tx); - if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId)) - { - //fprintf(stderr,"context failure\n"); - continue; - } - UpdateCoins(tx, view, nHeight); - - BOOST_FOREACH(const OutputDescription &outDescription, tx.vShieldedOutput) { - sapling_tree.append(outDescription.cm); - } - - // Added - pblock->vtx.push_back(tx); - pblocktemplate->vTxFees.push_back(nTxFees); - pblocktemplate->vTxSigOps.push_back(nTxSigOps); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; - ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); @@ -617,11 +495,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); -<<<<<<< HEAD - -======= ->>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed int32_t stakeHeight = chainActive.Height() + 1; //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);