mirror of
https://github.com/monero-project/monero.git
synced 2024-12-14 12:26:31 +02:00
core_tests: allow setting miner tx max_outs when creating a block
This commit is contained in:
parent
8e4c2e6ebe
commit
945fe90e08
@ -215,13 +215,14 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
|
|||||||
const crypto::hash& prev_id/* = crypto::hash()*/, const difficulty_type& diffic/* = 1*/,
|
const crypto::hash& prev_id/* = crypto::hash()*/, const difficulty_type& diffic/* = 1*/,
|
||||||
const transaction& miner_tx/* = transaction()*/,
|
const transaction& miner_tx/* = transaction()*/,
|
||||||
const std::vector<crypto::hash>& tx_hashes/* = std::vector<crypto::hash>()*/,
|
const std::vector<crypto::hash>& tx_hashes/* = std::vector<crypto::hash>()*/,
|
||||||
size_t txs_sizes/* = 0*/)
|
size_t txs_sizes/* = 0*/, size_t max_outs/* = 0*/)
|
||||||
{
|
{
|
||||||
blk.major_version = actual_params & bf_major_ver ? major_ver : CURRENT_BLOCK_MAJOR_VERSION;
|
blk.major_version = actual_params & bf_major_ver ? major_ver : CURRENT_BLOCK_MAJOR_VERSION;
|
||||||
blk.minor_version = actual_params & bf_minor_ver ? minor_ver : CURRENT_BLOCK_MINOR_VERSION;
|
blk.minor_version = actual_params & bf_minor_ver ? minor_ver : CURRENT_BLOCK_MINOR_VERSION;
|
||||||
blk.timestamp = actual_params & bf_timestamp ? timestamp : prev_block.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN; // Keep difficulty unchanged
|
blk.timestamp = actual_params & bf_timestamp ? timestamp : prev_block.timestamp + DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN; // Keep difficulty unchanged
|
||||||
blk.prev_id = actual_params & bf_prev_id ? prev_id : get_block_hash(prev_block);
|
blk.prev_id = actual_params & bf_prev_id ? prev_id : get_block_hash(prev_block);
|
||||||
blk.tx_hashes = actual_params & bf_tx_hashes ? tx_hashes : std::vector<crypto::hash>();
|
blk.tx_hashes = actual_params & bf_tx_hashes ? tx_hashes : std::vector<crypto::hash>();
|
||||||
|
max_outs = actual_params & bf_max_outs ? max_outs : 1;
|
||||||
|
|
||||||
size_t height = get_block_height(prev_block) + 1;
|
size_t height = get_block_height(prev_block) + 1;
|
||||||
uint64_t already_generated_coins = get_already_generated_coins(prev_block);
|
uint64_t already_generated_coins = get_already_generated_coins(prev_block);
|
||||||
@ -235,7 +236,7 @@ bool test_generator::construct_block_manually(block& blk, const block& prev_bloc
|
|||||||
{
|
{
|
||||||
size_t current_block_size = txs_sizes + get_object_blobsize(blk.miner_tx);
|
size_t current_block_size = txs_sizes + get_object_blobsize(blk.miner_tx);
|
||||||
// TODO: This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
|
// TODO: This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
|
||||||
if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, current_block_size, 0, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), 1))
|
if (!construct_miner_tx(height, misc_utils::median(block_sizes), already_generated_coins, current_block_size, 0, miner_acc.get_keys().m_account_address, blk.miner_tx, blobdata(), max_outs))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,8 @@ public:
|
|||||||
bf_prev_id = 1 << 3,
|
bf_prev_id = 1 << 3,
|
||||||
bf_miner_tx = 1 << 4,
|
bf_miner_tx = 1 << 4,
|
||||||
bf_tx_hashes = 1 << 5,
|
bf_tx_hashes = 1 << 5,
|
||||||
bf_diffic = 1 << 6
|
bf_diffic = 1 << 6,
|
||||||
|
bf_max_outs = 1 << 7
|
||||||
};
|
};
|
||||||
|
|
||||||
void get_block_chain(std::vector<block_info>& blockchain, const crypto::hash& head, size_t n) const;
|
void get_block_chain(std::vector<block_info>& blockchain, const crypto::hash& head, size_t n) const;
|
||||||
@ -240,7 +241,7 @@ public:
|
|||||||
const cryptonote::account_base& miner_acc, int actual_params = bf_none, uint8_t major_ver = 0,
|
const cryptonote::account_base& miner_acc, int actual_params = bf_none, uint8_t major_ver = 0,
|
||||||
uint8_t minor_ver = 0, uint64_t timestamp = 0, const crypto::hash& prev_id = crypto::hash(),
|
uint8_t minor_ver = 0, uint64_t timestamp = 0, const crypto::hash& prev_id = crypto::hash(),
|
||||||
const cryptonote::difficulty_type& diffic = 1, const cryptonote::transaction& miner_tx = cryptonote::transaction(),
|
const cryptonote::difficulty_type& diffic = 1, const cryptonote::transaction& miner_tx = cryptonote::transaction(),
|
||||||
const std::vector<crypto::hash>& tx_hashes = std::vector<crypto::hash>(), size_t txs_sizes = 0);
|
const std::vector<crypto::hash>& tx_hashes = std::vector<crypto::hash>(), size_t txs_sizes = 0, size_t max_outs = 0);
|
||||||
bool construct_block_manually_tx(cryptonote::block& blk, const cryptonote::block& prev_block,
|
bool construct_block_manually_tx(cryptonote::block& blk, const cryptonote::block& prev_block,
|
||||||
const cryptonote::account_base& miner_acc, const std::vector<crypto::hash>& tx_hashes, size_t txs_size);
|
const cryptonote::account_base& miner_acc, const std::vector<crypto::hash>& tx_hashes, size_t txs_size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user