33 #include <cuda/eqcuda.hpp> 41 #include <libgpusolver/libgpusolver.h> 44 #include <boost/thread.hpp> 45 #include <boost/tuple/tuple.hpp> 67 int64_t nOldTime = pblock->
nTime;
70 if (nOldTime < nNewTime)
71 pblock->
nTime = nNewTime;
77 return nNewTime - nOldTime;
144 int i=contrTx.
vout.size();
147 contrTx.
vout[i]=vout;
150 pblock->
vtx[refundtx] = MakeTransactionRef(std::move(contrTx));
182 if ( txProofTime == 0 ) {
210 coinbaseTx.
vin.resize(1);
211 coinbaseTx.
vin[0].prevout.SetNull();
212 coinbaseTx.
vout.resize(1);
214 coinbaseTx.
vout[0].scriptPubKey = scriptPubKeyIn;
218 pblock->
vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
225 uint32_t blockSizeDGP = fascDGP.getBlockSize(
nHeight);
242 int nPackagesSelected = 0;
243 int nDescendantsUpdated = 0;
260 LogPrintf(
"CreateNewBlock(): nHeight=%d total size: %u block weight: %u txs: %u fees: %ld sigops %d\n",
292 LogPrint(
BCLog::BENCH,
"CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart));
301 for (CTxMemPool::setEntries::iterator iit = testSet.begin(); iit != testSet.end(); ) {
304 testSet.erase(iit++);
355 if(!convert.extractionFascTransactions(resultConverter)){
360 std::vector<FascTransaction> fascTransactions = resultConverter.first;
363 txGas += fascTransaction.gas();
402 nBlockWeight += iter->GetTxWeight();
403 nBlockSigOpsCost += iter->GetSigOpCost();
420 int i=contrTx.
vout.size();
423 contrTx.
vout[i]=vout;
446 pblock->
vtx.emplace_back(iter->GetSharedTx());
449 this->nBlockWeight += iter->GetTxWeight();
451 this->nBlockSigOpsCost += iter->GetSigOpCost();
452 nFees += iter->GetFee();
456 pblock->
vtx.emplace_back(MakeTransactionRef(std::move(t)));
474 pblock->
vtx.emplace_back(iter->GetSharedTx());
480 nFees += iter->GetFee();
483 bool fPrintPriority =
gArgs.
GetBoolArg(
"-printpriority", DEFAULT_PRINTPRIORITY);
484 if (fPrintPriority) {
486 CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(),
487 iter->GetTx().GetHash().
ToString());
494 int nDescendantsUpdated = 0;
500 if (alreadyAdded.count(desc))
502 ++nDescendantsUpdated;
503 modtxiter mit = mapModifiedTx.find(desc);
504 if (mit == mapModifiedTx.end()) {
509 mapModifiedTx.insert(modEntry);
515 return nDescendantsUpdated;
530 return mapModifiedTx.count(it) ||
inBlock.count(it) || failedTx.count(it);
539 sortedEntries.clear();
540 sortedEntries.insert(sortedEntries.begin(), package.begin(), package.end());
572 const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
573 int64_t nConsecutiveFailed = 0;
590 bool fUsingModified =
false;
596 fUsingModified =
true;
606 fUsingModified =
true;
618 uint64_t packageSize = iter->GetSizeWithAncestors();
619 CAmount packageFees = iter->GetModFeesWithAncestors();
620 int64_t packageSigOpsCost = iter->GetSigOpCostWithAncestors();
621 if (fUsingModified) {
622 packageSize = modit->nSizeWithAncestors;
623 packageFees = modit->nModFeesWithAncestors;
624 packageSigOpsCost = modit->nSigOpCostWithAncestors;
632 if (!
TestPackage(packageSize, packageSigOpsCost)) {
633 if (fUsingModified) {
638 failedTx.insert(iter);
641 ++nConsecutiveFailed;
643 if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES &&
nBlockWeight >
657 ancestors.insert(iter);
661 if (fUsingModified) {
663 failedTx.insert(iter);
669 nConsecutiveFailed = 0;
672 std::vector<CTxMemPool::txiter> sortedEntries;
676 for (
size_t i=0; i<sortedEntries.size(); ++i) {
680 mapModifiedTx.erase(sortedEntries[i]);
692 failedTx.insert(iter);
700 mapModifiedTx.erase(sortedEntries[i]);
728 assert(txCoinbase.
vin[0].scriptSig.size() <= 100);
730 pblock->
vtx[0] = MakeTransactionRef(std::move(txCoinbase));
756 return error(
"FabcoinMiner: generated block is stale");
763 bool fNewBlock =
false;
764 std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
766 return error(
"FabcoinMiner: ProcessNewBlock, block not accepted");
773 static const unsigned int nInnerLoopCount = 0x0FFFFFFF;
780 LogPrintf(
"FabcoinMiner thread(%d) started on CPU \n", thr_id);
785 unsigned int nExtraNonce = 0;
786 std::shared_ptr<CReserveScript> coinbaseScript;
792 unsigned int n = chainparams.
EquihashN();
793 unsigned int k = chainparams.
EquihashK();
796 uint8_t * header = NULL;
807 bool cancelSolver =
false;
819 if (!coinbaseScript || coinbaseScript->reserveScript.empty())
820 throw std::runtime_error(
"No coinbase script available (mining requires a wallet)");
841 if (!pblocktemplate.get())
843 LogPrintf(
"Error in FabcoinMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
846 CBlock *pblock = &pblocktemplate->block;
852 LogPrintf(
"FabcoinMiner mining with %u transactions in block (%u bytes) @(%s) n=%d, k=%d\n", pblock->
vtx.size(),
871 auto t = std::chrono::high_resolution_clock::now();
880 crypto_generichash_blake2b_state state;
884 crypto_generichash_blake2b_update(&state, (
unsigned char*)&ss[0], ss.
size());
894 crypto_generichash_blake2b_state curr_state;
900 header[headerlen-32 + i] = pblock->
nNonce.
begin()[i];
910 std::function<bool(std::vector<unsigned char>)> validBlock =
911 [&pblock, &hashTarget, &m_cs, &cancelSolver, &chainparams,thr_id](std::vector<unsigned char> soln)
928 if (ProcessBlockFound(pblock, chainparams))
931 std::lock_guard<std::mutex> lock{m_cs};
932 cancelSolver =
false;
939 throw boost::thread_interrupted();
945 std::function<bool(GPUSolverCancelCheck)> cancelledGPU = [&m_cs, &cancelSolver](
GPUSolverCancelCheck pos) {
946 std::lock_guard<std::mutex> lock{m_cs};
950 std::function<bool(EhSolverCancelCheck)> cancelled = [&m_cs, &cancelSolver](
EhSolverCancelCheck pos) {
951 std::lock_guard<std::mutex> lock{m_cs};
969 std::pair<int,int> param = g_solver->
getparam();
970 if( param.first != n || param.second != k )
976 bool found = g_solver->
run(n, k, header, headerlen, pblock->
nNonce, validBlock, cancelledGPU, curr_state);
983 std::lock_guard<std::mutex> lock{m_cs};
984 cancelSolver =
false;
988 boost::this_thread::interruption_point();
993 if ( nCounter == nInnerLoopCount )
1028 auto d = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - t);
1029 auto milis = std::chrono::duration_cast<std::chrono::milliseconds>(
d).
count();
1030 secs = (1.0 * milis)/1000;
1031 solps = (double)
g_nSols[thr_id] / secs;
1035 catch (
const boost::thread_interrupted&)
1045 catch (
const std::runtime_error &
e)
1047 LogPrintf(
"FabcoinMiner runtime error: %s\n", e.what());
1065 #if defined(ENABLE_GPU) && defined(USE_CUDA) 1067 static bool cb_cancel()
1072 static bool cb_validate(std::vector<unsigned char> sols,
unsigned char *pblockdata,
int thrid)
1090 if (ProcessBlockFound(pblock, chainparams))
1105 static const unsigned int nInnerLoopCount = 0x0FFFFFFF;
1106 unsigned int nCounter = 0;
1114 unsigned int nExtraNonce = 0;
1115 std::shared_ptr<CReserveScript> coinbaseScript;
1121 unsigned int n = chainparams.
EquihashN();
1122 unsigned int k = chainparams.
EquihashK();
1124 uint8_t * header = NULL;
1133 if (!coinbaseScript || coinbaseScript->reserveScript.empty())
1134 throw std::runtime_error(
"No coinbase script available (mining requires a wallet)");
1155 if (!pblocktemplate.get())
1157 LogPrintf(
"Error in FabcoinMinerCuda: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
1160 CBlock *pblock = &pblocktemplate->block;
1164 LogPrintf(
"FabcoinMiner mining with %u transactions in block (%u bytes) @(%s) n=%d, k=%d\n", pblock->
vtx.size(),
1175 delete g_solver184_7;
1176 g_solver184_7 = NULL;
1192 if( !g_solver184_7 )
1198 catch (
const std::runtime_error &
e)
1201 std::lock_guard<std::mutex> lock{
g_cs};
1218 auto t = std::chrono::high_resolution_clock::now();
1228 header[headerlen-32 + i] = pblock->
nNonce.
begin()[i];
1236 found = g_solver->
solve((
unsigned char *)pblock, header, headerlen);
1241 found = g_solver184_7->
solve((
unsigned char *)pblock, header, headerlen);
1247 std::lock_guard<std::mutex> lock{
g_cs};
1252 boost::this_thread::interruption_point();
1257 if ( nCounter == nInnerLoopCount )
1291 auto d = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - t);
1292 auto milis = std::chrono::duration_cast<std::chrono::milliseconds>(
d).
count();
1293 secs = (1.0 * milis)/1000;
1294 solps = (double)
g_nSols[thr_id] / secs;
1298 catch (
const boost::thread_interrupted&)
1305 delete g_solver184_7;
1310 catch (
const std::runtime_error &
e)
1312 LogPrintf(
"FabcoinMiner runtime error: %s\n", e.what());
1317 delete g_solver184_7;
1327 delete g_solver184_7;
1333 static boost::thread_group* minerThreads = NULL;
1340 if (minerThreads != NULL)
1342 minerThreads->interrupt_all();
1343 minerThreads->join_all();
1344 delete minerThreads;
1345 minerThreads = NULL;
1348 if (nThreads == 0 || !fGenerate)
1361 if (minerThreads != NULL)
1363 minerThreads->interrupt_all();
1364 minerThreads->join_all();
1365 delete minerThreads;
1366 minerThreads = NULL;
1369 if (nThreads == 0 || !fGenerate)
1372 minerThreads =
new boost::thread_group();
1373 int thread_sequence = 0;
1386 int devicesFound = 0;
1387 unsigned numPlatforms = platforms.size();
1389 for(
unsigned platform = 0; platform < numPlatforms; ++platform)
1392 std::string infolow;
1393 bool bNvidiaDev =
false;
1395 infolow.resize(info.size());
1396 std::transform(info.begin(),info.end(),infolow.begin(),::tolower);
1397 if( infolow.find(
"nvidia") != std::string::npos )
1402 unsigned noDevices = devices.size();
1403 devicesFound += noDevices;
1406 for(
unsigned device = 0; device < noDevices; ++device) {
1412 devices[device].getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &result);
1414 int maxThreads = nThreads;
1421 if (result > 7500000000) {
1422 maxThreads =
std::min(4, nThreads);
1423 }
else if (result > 5500000000) {
1424 maxThreads =
std::min(3, nThreads);
1425 }
else if (result > 3500000000) {
1426 maxThreads =
std::min(2, nThreads);
1428 maxThreads =
std::min(1, nThreads);
1433 if (result > 7500000000) {
1434 maxThreads =
std::min(2, nThreads);
1436 maxThreads =
std::min(1, nThreads);
1443 for (
int i = 0; i < maxThreads; i++){
1444 if ( thread_sequence > 255 ){
1451 if( bNvidiaDev && conf.
useCUDA ){
1453 minerThreads->create_thread(boost::bind(&FabcoinMinerCuda, boost::cref(chainparams), conf, thread_sequence ));
1457 minerThreads->create_thread(boost::bind(&FabcoinMiner, boost::cref(chainparams), conf, thread_sequence ));
1463 if (devicesFound <= 0) {
1464 LogPrintf(
"GenerateFabcoins ERROR, No OpenCL devices found!\n");
1473 std::string infolow;
1474 bool bNvidiaDev =
false;
1476 infolow.resize(info.size());
1477 std::transform(info.begin(),info.end(),infolow.begin(),::tolower);
1478 if( infolow.find(
"nvidia") != std::string::npos )
1488 devices[conf.
currentDevice].getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &result);
1490 int maxThreads = nThreads;
1493 if (result > 7500000000) {
1494 maxThreads =
std::min(4, nThreads);
1495 }
else if (result > 5500000000) {
1496 maxThreads =
std::min(3, nThreads);
1497 }
else if (result > 3500000000) {
1498 maxThreads =
std::min(2, nThreads);
1500 maxThreads =
std::min(1, nThreads);
1507 for (
int i = 0; i < maxThreads; i++) {
1509 if ( thread_sequence > 255 ){
1517 if( bNvidiaDev && conf.
useCUDA ){
1519 minerThreads->create_thread(boost::bind(&FabcoinMinerCuda, boost::cref(chainparams), conf, thread_sequence ));
1523 minerThreads->create_thread(boost::bind(&FabcoinMiner, boost::cref(chainparams), conf, thread_sequence ));
1528 LogPrintf(
"GenerateFabcoins ERROR, No OpenCL devices found!\n");
1535 for (
int i = 0; i < nThreads; i++){
1536 LogPrintf(
"GenerateFabcoins CPU, thread=%d!\n", i);
1537 minerThreads->create_thread(boost::bind(&FabcoinMiner, boost::cref(chainparams), conf, i));
1545 bool cancelSolver =
false;
1546 uint64_t nMaxTries = 0;
1557 crypto_generichash_blake2b_state state;
1566 crypto_generichash_blake2b_update(&state, (
unsigned char*) &ss[0], ss.
size());
1569 crypto_generichash_blake2b_state curr_state;
1577 std::function<bool(std::vector<unsigned char>) > validBlock =
1578 [&pblock, &hashTarget, &cancelSolver ](std::vector<unsigned char> soln) {
1595 std::function<bool(EhSolverCancelCheck) > cancelled = [ &cancelSolver](
EhSolverCancelCheck pos) {
1596 return cancelSolver;
1605 LogPrintf(
"Block ------------------ \n%s\n ----------------", pblock->
ToString());
1611 cancelSolver =
false;
1622 const char* pszTimestamp =
"Fabcoin1ff5c8707d920ee573f5f1d43e559dfa3e4cb3f97786e8cb1685c991786b2";
1627 txNew.
vin.resize(1);
1628 txNew.
vout.resize(1);
1630 txNew.
vin[0].scriptSig =
CScript() << 00 << 520617983 <<
CScriptNum(4) << std::vector<unsigned char>((
const unsigned char*)pszTimestamp, (
const unsigned char*)pszTimestamp + strlen(pszTimestamp));
1632 txNew.
vout[0].nValue = 25 * COIN;
1633 txNew.
vout[0].scriptPubKey = genesisOutputScript;
1637 pblock.
nTime = nTime;
1638 pblock.
nBits = nBits;
1642 pblock.
vtx.push_back(MakeTransactionRef(std::move(txNew)));
1647 const size_t N = 48, K = 5;
1650 std::cerr << pblock.
ToString() << std::endl;
1652 #endif // ENABLE_WALLET static std::string platform_info(unsigned _platformId=0, unsigned _deviceId=0)
std::pair< std::vector< FascTransaction >, std::vector< EthTransactionParams >> ExtractFascTX
indexed_modified_transaction_set::nth_index< 0 >::type::iterator modtxiter
bool TestPackageTransactions(const CTxMemPool::setEntries &package)
Perform checks on each transaction in a package: locktime, premature-witness, serialized size (if nec...
bool error(const char *fmt, const Args &...args)
bool solve(unsigned char *pblock, unsigned char *header, unsigned int headerlen)
std::vector< CWalletRef > vpwallets
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
unsigned int nBlockMaxWeight
void addPackageTxs(int &nPackagesSelected, int &nDescendantsUpdated, uint64_t minGasPrice)
Add transactions based on feerate including unconfirmed ancestors Increments nPackagesSelected / nDes...
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
void SetThreadPriority(int nPriority)
void MilliSleep(int64_t n)
int64_t GetTransactionWeight(const CTransaction &tx)
void SortForBlock(const CTxMemPool::setEntries &package, CTxMemPool::txiter entry, std::vector< CTxMemPool::txiter > &sortedEntries)
Sort the package in an order that is valid to appear in a block.
void AddToBlock(CTxMemPool::txiter iter)
Add a tx to the block.
bool IsArgSet(const std::string &strArg)
Return true if the given argument has been manually set.
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
bool performByteCode(dev::eth::Permanence type=dev::eth::Permanence::Committed)
unsigned int EquihashN(uint32_t nHeight=0) const
uint64_t hardBlockGasLimit
#define EhInitialiseState(n, k, base_state)
size_t GetSerializeSize(const T &t, int nType, int nVersion=0)
void onlyUnconfirmed(CTxMemPool::setEntries &testSet)
Remove confirmed (inBlock) entries from given set.
std::string GetHex() const
CMutableTransaction originalRewardTx
const Consensus::Params & GetConsensus() const
CTxMemPool::setEntries inBlock
std::unique_ptr< CBlockTemplate > pblocktemplate
void BlockFound(const uint256 &)
bool fPowAllowMinDifficultyBlocks
int64_t dgpMaxBlockSigOps
The maximum allowed number of signature check operations in a block (network rule) ...
bool run(unsigned int n, unsigned int k, uint8_t *header, size_t header_len, uint256 nonce, const std::function< bool(std::vector< unsigned char >)> validBlock, const std::function< bool(GPUSolverCancelCheck)> cancelled, crypto_generichash_blake2b_state base_state)
void GenerateFabcoins(bool fGenerate, int nThreads, const CChainParams &chainparams)
Run the miner threads.
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
std::set< txiter, CompareIteratorByHash > setEntries
assert(len-trim+(2 *lenIndices)<=WIDTH)
CChainParams defines various tweakable parameters of a given instance of the Fabcoin system...
std::unique_ptr< CBlockTemplate > CreateNewBlock(const CScript &scriptPubKeyIn, bool fMineWitnessTx=true, int64_t *pTotalFees=0, int32_t nTime=0, int32_t nTimeLimit=0)
Construct a new block template with coinbase to scriptPubKeyIn.
Double ended buffer combining vector and stream-like interfaces.
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms)
Determine what nVersion a new block should use.
bool ProcessNewBlock(const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock)
Process an incoming block.
static std::vector< cl::Platform > getPlatforms()
#define FABCOIN_NONCE_LEN
void RenameThread(const char *name)
uint32_t FABHeight
Block height at which Fabcoin Equihash hard fork becomes active.
arith_uint256 UintToArith256(const uint256 &a)
uint64_t nLastBlockWeight
std::string ToString() const
unsigned int GetTransactionsUpdated() const
indexed_transaction_set mapTx
int64_t CAmount
Amount in lius (Can be negative)
bool solve(unsigned char *pblock, unsigned char *header, unsigned int headerlen)
int64_t GetnPowTargetSpacing(uint32_t nHeight=0) const
#define THREAD_PRIORITY_NORMAL
boost::multi_index_container< CTxMemPoolModifiedEntry, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< modifiedentry_iter, CompareCTxMemPoolIter >, boost::multi_index::ordered_non_unique< boost::multi_index::tag< ancestor_score_or_gas_price >, boost::multi_index::identity< CTxMemPoolModifiedEntry >, CompareModifiedEntry > >> indexed_modified_transaction_set
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
void Scan_nNonce_nSolution(CBlock *pblock, unsigned int n, unsigned int k)
#define THREAD_PRIORITY_LOWEST
bool EhOptimisedSolve(unsigned int n, unsigned int k, const eh_HashState &base_state, const std::function< bool(std::vector< unsigned char >)> validBlock, const std::function< bool(EhSolverCancelCheck)> cancelled)
std::pair< int, int > getparam()
const CChainParams & chainparams
void CalculateDescendants(txiter it, setEntries &setDescendants)
Populate setDescendants with all in-mempool descendants of hash.
uint32_t ContractHeight
Block height at which Fabcoin Smart Contract hard fork becomes active.
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network) ...
BlockAssembler(const CChainParams ¶ms)
CMainSignals & GetMainSignals()
Generate a new block, without valid proof-of-work.
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
bool ParseMoney(const std::string &str, CAmount &nRet)
An output of a transaction.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Parameters that influence chain consensus.
CScript COINBASE_FLAGS
Constant stuff for coinbase transactions we create:
bool processingResults(ByteCodeExecResult &result)
std::vector< CTxOut > vout
std::string GetHex() const
int UpdatePackagesForAdded(const CTxMemPool::setEntries &alreadyAdded, indexed_modified_transaction_set &mapModifiedTx)
Add descendants of given transactions to mapModifiedTx with ancestor state updated assuming given tra...
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
256-bit unsigned big integer.
indexed_transaction_set::nth_index< 0 >::type::iterator txiter
uint64_t softBlockGasLimit
uint64_t nSizeWithAncestors
ByteCodeExecResult bceResult
Construct a new block template with coinbase to scriptPubKeyIn.
std::string ToString() const
#define LogPrint(category,...)
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
Modify the extranonce in a block.
std::string ToString() const
CAmount GetFee(size_t nBytes) const
Return the fee in liu for the given size in bytes.
uint64_t nBlockSigOpsCost
Capture information about block/transaction validation.
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, CTxMemPool::setEntries &failedTx)
Return true if given transaction from mapTx has already been evaluated, or if the transaction's cache...
CAmount nModFeesWithAncestors
void creategenesisblock(uint32_t nTime, uint32_t nBits)
uint256 ArithToUint256(const arith_uint256 &a)
std::vector< CTransactionRef > vtx
std::string FormatStateMessage(const CValidationState &state)
Convert CValidationState to a human-readable message for logging.
unsigned int GetLegacySigOpCount(const CTransaction &tx)
Auxiliary functions for transaction validation (ideally should not be exposed)
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Serialized script, used inside transaction inputs and outputs.
void * memcpy(void *a, const void *b, size_t c)
bool AttemptToAddContractToBlock(CTxMemPool::txiter iter, uint64_t minGasPrice)
std::vector< unsigned char > GenerateCoinbaseCommitment(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Produce the necessary coinbase commitment for a block (modifies the hash, don't call for mined blocks...
int64_t GetAdjustedTime()
bool TestBlockValidity(CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
Check a block is completely valid from start to finish (only works on top of our current best block...
unsigned int GetNextWorkRequired(const CBlockIndex *pindexPrev, const CBlockHeader *pblock, const Consensus::Params ¶ms)
bool HasCreateOrCall() const
int64_t nSigOpCostWithAncestors
uint32_t EquihashFABHeight
Block height at which EquihashFAB (184,7) becomes active.
Fee rate in liu per kilobyte: CAmount / kB.
std::unique_ptr< CConnman > g_connman
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
bool IsWitnessEnabled(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms)
Check whether witness commitments are required for block.
void resetBlock()
Clear the block's state and prepare for assembling a new block.
A mutable version of CTransaction.
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
Check if transaction is final and can be included in a block with the specified height and time...
bool TestPackage(uint64_t packageSize, int64_t packageSigOpsCost)
Test if a new package would "fit" in the block.
std::vector< CTxOut > refundOutputs
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
indexed_modified_transaction_set::index< ancestor_score_or_gas_price >::type::iterator modtxscoreiter
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
int GetNumCores()
Return the number of physical cores available on the current system.
void ScriptForMining(std::shared_ptr< CReserveScript > &coinbaseScript)
bool MiningRequiresPeers() const
Make miner wait to have peers to avoid wasting work.
void RebuildRefundTransaction()
Rebuild the coinbase/coinstake transaction to account for new gas refunds.
int64_t GetBlockTime() const
int64_t GetMedianTimePast() const
bool IsBlockTooLate(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
unsigned int EquihashK(uint32_t nHeight=0) const
static std::vector< cl::Device > getDevices(std::vector< cl::Platform > const &_platforms, unsigned _platformId)
std::unique_ptr< FascState > globalState
Global state.
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true) const
Try to calculate all in-mempool ancestors of entry.
uint256 h256Touint(const dev::h256 &in)
std::shared_ptr< dev::eth::SealEngineFace > globalSealEngine
uint256 GetBlockHash() const
unsigned int dgpMaxBlockWeight
The maximum allowed weight for a block, see BIP 141 (network rule)
unsigned int size() const
std::vector< unsigned char > ParseHex(const char *psz)
std::vector< CTransaction > valueTransfers