Fix bug where GetNextWorkRequired did not know about randomx
This commit is contained in:
@@ -391,6 +391,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
|
||||
// Priority is sum(valuein * age) / modified_txsize
|
||||
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||
fprintf(stderr,"%s: computing priority with nTxSize=%u\n", __func__, nTxSize);
|
||||
dPriority = tx.ComputePriority(dPriority, nTxSize);
|
||||
|
||||
uint256 hash = tx.GetHash();
|
||||
@@ -436,6 +437,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"%s: done adding txs from mempool\n", __func__);
|
||||
|
||||
// Collect transactions into block
|
||||
int64_t interest;
|
||||
@@ -447,13 +449,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
TxPriorityCompare comparer(fSortedByFee);
|
||||
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
|
||||
fprintf(stderr,"%s: compared txs with fSortedByFee=%d\n", __func__, fSortedByFee);
|
||||
|
||||
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>());
|
||||
|
||||
fprintf(stderr,"%s: grabbed first tx from priority queue\n", __func__);
|
||||
|
||||
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
fprintf(stderr,"%s: compared first tx from priority queue\n", __func__);
|
||||
vecPriority.pop_back();
|
||||
|
||||
// Size limits
|
||||
@@ -591,10 +598,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
|
||||
nLastBlockTx = nBlockTx;
|
||||
nLastBlockSize = nBlockSize;
|
||||
fprintf(stderr,"%s: nLastBlockTx=%lu , nLastBlockSize=%lu\n", __func__, nLastBlockTx, nLastBlockSize);
|
||||
|
||||
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
||||
blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
||||
else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetTime());
|
||||
//pblock->nTime = blocktime + 1;
|
||||
fprintf(stderr,"%s: calling GetNextWorkRequired\n", __func__);
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
|
||||
LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
|
||||
|
||||
Reference in New Issue
Block a user