bool test_generator::constructBlockManually(Block& blk, const Block& prevBlock, const account_base& minerAcc, int actualParams/* = bf_none*/, uint8_t majorVer/* = 0*/, uint8_t minorVer/* = 0*/, uint64_t timestamp/* = 0*/, const crypto::hash& prevId/* = crypto::hash()*/, const difficulty_type& diffic/* = 1*/, const Transaction& minerTx/* = transaction()*/, const std::vector<crypto::hash>& txHashes/* = std::vector<crypto::hash>()*/, size_t txsSizes/* = 0*/, uint64_t fee/* = 0*/) { blk.majorVersion = actualParams & bf_major_ver ? majorVer : defaultMajorVersion; blk.minorVersion = actualParams & bf_minor_ver ? minorVer : defaultMinorVersion; blk.timestamp = actualParams & bf_timestamp ? timestamp : prevBlock.timestamp + m_currency.difficultyTarget(); // Keep difficulty unchanged blk.prevId = actualParams & bf_prev_id ? prevId : get_block_hash(prevBlock); blk.txHashes = actualParams & bf_tx_hashes ? txHashes : std::vector<crypto::hash>(); uint32_t height = get_block_height(prevBlock) + 1; uint64_t alreadyGeneratedCoins = getAlreadyGeneratedCoins(prevBlock); std::vector<size_t> blockSizes; getLastNBlockSizes(blockSizes, get_block_hash(prevBlock), m_currency.rewardBlocksWindow()); if (actualParams & bf_miner_tx) { blk.minerTx = minerTx; } else { size_t currentBlockSize = txsSizes + get_object_blobsize(blk.minerTx); // TODO: This will work, until size of constructed block is less then m_currency.blockGrantedFullRewardZone() if (!m_currency.constructMinerTx(height, Common::medianValue(blockSizes), alreadyGeneratedCoins, currentBlockSize, 0, minerAcc.get_keys().m_account_address, blk.minerTx, blobdata(), 1, blk.majorVersion > BLOCK_MAJOR_VERSION_1)) { return false; } } if (blk.majorVersion >= BLOCK_MAJOR_VERSION_2) { blk.parentBlock.majorVersion = BLOCK_MAJOR_VERSION_1; blk.parentBlock.minorVersion = BLOCK_MINOR_VERSION_0; blk.parentBlock.numberOfTransactions = 1; CryptoNote::tx_extra_merge_mining_tag mmTag; mmTag.depth = 0; if (!CryptoNote::get_aux_block_header_hash(blk, mmTag.merkle_root)) { return false; } blk.parentBlock.minerTx.extra.clear(); if (!CryptoNote::append_mm_tag_to_extra(blk.parentBlock.minerTx.extra, mmTag)) { return false; } } difficulty_type aDiffic = actualParams & bf_diffic ? diffic : getTestDifficulty(); if (1 < aDiffic) { fillNonce(blk, aDiffic); } addBlock(blk, txsSizes, fee, blockSizes, alreadyGeneratedCoins); return true; }
std::string Currency::accountAddressAsString(const account_base& account) const { return getAccountAddressAsStr(m_publicAddressBase58Prefix, account.get_keys().m_account_address); }