fix miner.cpp
This commit is contained in:
128
src/miner.cpp
128
src/miner.cpp
@@ -213,13 +213,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
// we will attempt to spend any cheats we see
|
// we will attempt to spend any cheats we see
|
||||||
CTransaction cheatTx;
|
CTransaction cheatTx;
|
||||||
boost::optional<CTransaction> cheatSpend;
|
boost::optional<CTransaction> cheatSpend;
|
||||||
<<<<<<< HEAD
|
|
||||||
uint256 cbHash;
|
uint256 cbHash;
|
||||||
|
|
||||||
=======
|
|
||||||
uint256 cbHash;
|
|
||||||
|
|
||||||
>>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed
|
|
||||||
CBlockIndex* pindexPrev = 0;
|
CBlockIndex* pindexPrev = 0;
|
||||||
{
|
{
|
||||||
ENTER_CRITICAL_SECTION(cs_main);
|
ENTER_CRITICAL_SECTION(cs_main);
|
||||||
@@ -289,7 +285,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
bool fNotarisation = false;
|
bool fNotarisation = false;
|
||||||
if (tx.IsCoinImport())
|
if (tx.IsCoinImport())
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
CAmount nValueIn = GetCoinImportValue(tx); // burn amount
|
CAmount nValueIn = GetCoinImportValue(tx); // burn amount
|
||||||
nTotalIn += nValueIn;
|
nTotalIn += nValueIn;
|
||||||
dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16.
|
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 )
|
if ( komodo_is_notarytx(tx) == 1 )
|
||||||
fToCryptoAddress = true;
|
fToCryptoAddress = true;
|
||||||
|
|
||||||
=======
|
|
||||||
CAmount nValueIn = GetCoinImportValue(tx);
|
|
||||||
nTotalIn += nValueIn;
|
|
||||||
dPriority += (double)nValueIn * 1000; // flat multiplier
|
|
||||||
} else {
|
|
||||||
>>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||||
{
|
{
|
||||||
// Read prev transaction
|
// Read prev transaction
|
||||||
@@ -342,7 +331,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
|
|
||||||
int nConf = nHeight - coins->nHeight;
|
int nConf = nHeight - coins->nHeight;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// This is to test is a tx is a notarisation and assign it max priotity.
|
// This is to test is a tx is a notarisation and assign it max priotity.
|
||||||
if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 )
|
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 )
|
if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 )
|
||||||
fNotarisation = true;
|
fNotarisation = true;
|
||||||
=======
|
|
||||||
dPriority += (double)nValueIn * nConf;
|
|
||||||
}
|
}
|
||||||
>>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed
|
|
||||||
nTotalIn += tx.GetShieldedValueIn();
|
nTotalIn += tx.GetShieldedValueIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,22 +361,10 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
|
|
||||||
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (fNotarisation) {
|
if (fNotarisation) {
|
||||||
dPriority = 1e16;
|
dPriority = 1e16;
|
||||||
//fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str());
|
//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)
|
if (porphan)
|
||||||
{
|
{
|
||||||
porphan->dPriority = dPriority;
|
porphan->dPriority = dPriority;
|
||||||
@@ -494,101 +467,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
nBlockSigOps += nTxSigOps;
|
nBlockSigOps += nTxSigOps;
|
||||||
nFees += nTxFees;
|
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)
|
if (fPrintPriority)
|
||||||
{
|
{
|
||||||
LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString());
|
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());
|
blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||||
//pblock->nTime = blocktime + 1;
|
//pblock->nTime = blocktime + 1;
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> dac67400a4078a965fc76b0ab0c08bf316287fed
|
|
||||||
int32_t stakeHeight = chainActive.Height() + 1;
|
int32_t stakeHeight = chainActive.Height() + 1;
|
||||||
|
|
||||||
//LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
|
//LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
|
||||||
|
|||||||
Reference in New Issue
Block a user