Fix bug where GetNextWorkRequired did not know about randomx
This commit is contained in:
@@ -568,7 +568,7 @@ extern int32_t ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,
|
||||
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD;
|
||||
extern int32_t ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME;
|
||||
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
|
||||
extern uint32_t ASSETCHAINS_ALGO,ASSETCHAINS_EQUIHASH,HUSH_INITDONE;
|
||||
extern uint32_t ASSETCHAINS_ALGO,ASSETCHAINS_EQUIHASH,ASSETCHAINS_RANDOMX, HUSH_INITDONE;
|
||||
extern int32_t HUSH_MININGTHREADS,HUSH_LONGESTCHAIN,ASSETCHAINS_SEED,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,HUSH_CHOSEN_ONE,HUSH_ON_DEMAND,HUSH_PASSPORT_INITDONE,ASSETCHAINS_STAKED,HUSH_NSPV;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET;
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -297,8 +297,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
if (pindexLast->GetHeight() == 340000) {
|
||||
LogPrintf("%s: Using blocktime=%d\n",__func__,ASSETCHAINS_BLOCKTIME);
|
||||
}
|
||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
||||
//if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
|
||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_ALGO != ASSETCHAINS_RANDOMX) {
|
||||
fprintf(stderr,"%s: using lwma for next work\n",__func__);
|
||||
return lwmaGetNextWorkRequired(pindexLast, pblock, params);
|
||||
}
|
||||
|
||||
arith_uint256 bnLimit;
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH)
|
||||
@@ -500,7 +503,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
nbits = bnTarget.GetCompact();
|
||||
nbits = (nbits & 0xfffffffc) | zawyflag;
|
||||
}
|
||||
if(fDebug)
|
||||
//if(fDebug)
|
||||
fprintf(stderr,"%s: nbits=%d\n", __func__, nbits);
|
||||
return(nbits);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user