mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
replace std::list with std::vector on some hot paths
also use reserve where appropriate
This commit is contained in:
parent
209ec963b5
commit
ed2c81ed95
28 changed files with 257 additions and 233 deletions
|
|
@ -128,7 +128,7 @@ bool gen_chain_switch_1::check_split_not_switched(cryptonote::core& c, size_t ev
|
|||
m_recipient_account_3 = boost::get<account_base>(events[3]);
|
||||
m_recipient_account_4 = boost::get<account_base>(events[4]);
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 10000, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
CHECK_EQ(5 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks.size());
|
||||
|
|
@ -145,7 +145,7 @@ bool gen_chain_switch_1::check_split_not_switched(cryptonote::core& c, size_t ev
|
|||
CHECK_EQ(MK_COINS(14), get_balance(m_recipient_account_3, chain, mtx));
|
||||
CHECK_EQ(MK_COINS(3), get_balance(m_recipient_account_4, chain, mtx));
|
||||
|
||||
std::list<transaction> tx_pool;
|
||||
std::vector<transaction> tx_pool;
|
||||
r = c.get_pool_transactions(tx_pool);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
CHECK_EQ(1, tx_pool.size());
|
||||
|
|
@ -166,7 +166,7 @@ bool gen_chain_switch_1::check_split_switched(cryptonote::core& c, size_t ev_ind
|
|||
{
|
||||
DEFINE_TESTS_ERROR_CONTEXT("gen_chain_switch_1::check_split_switched");
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 10000, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
CHECK_EQ(6 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks.size());
|
||||
|
|
@ -175,7 +175,7 @@ bool gen_chain_switch_1::check_split_switched(cryptonote::core& c, size_t ev_ind
|
|||
CHECK_TEST_CONDITION(std::equal(blocks.begin(), it, m_chain_1.begin()));
|
||||
CHECK_TEST_CONDITION(blocks.back() == boost::get<block>(events[24 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW])); // blk_7
|
||||
|
||||
std::list<block> alt_blocks;
|
||||
std::vector<block> alt_blocks;
|
||||
r = c.get_alternative_blocks(alt_blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
CHECK_EQ(2, c.get_alternative_blocks_count());
|
||||
|
|
@ -195,7 +195,7 @@ bool gen_chain_switch_1::check_split_switched(cryptonote::core& c, size_t ev_ind
|
|||
CHECK_EQ(MK_COINS(14), get_balance(m_recipient_account_3, chain, mtx));
|
||||
CHECK_EQ(MK_COINS(16), get_balance(m_recipient_account_4, chain, mtx));
|
||||
|
||||
std::list<transaction> tx_pool;
|
||||
std::vector<transaction> tx_pool;
|
||||
r = c.get_pool_transactions(tx_pool);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
CHECK_EQ(1, tx_pool.size());
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ public:
|
|||
bool check_split_switched(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
|
||||
|
||||
private:
|
||||
std::list<cryptonote::block> m_chain_1;
|
||||
std::vector<cryptonote::block> m_chain_1;
|
||||
|
||||
cryptonote::account_base m_recipient_account_1;
|
||||
cryptonote::account_base m_recipient_account_2;
|
||||
cryptonote::account_base m_recipient_account_3;
|
||||
cryptonote::account_base m_recipient_account_4;
|
||||
|
||||
std::list<cryptonote::transaction> m_tx_pool;
|
||||
std::vector<cryptonote::transaction> m_tx_pool;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ inline bool do_replay_events(std::vector<test_event_entry>& events)
|
|||
MERROR("Failed to flush txpool");
|
||||
return false;
|
||||
}
|
||||
c.get_blockchain_storage().flush_txes_from_pool(std::list<crypto::hash>(pool_txs.begin(), pool_txs.end()));
|
||||
c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
|
||||
|
||||
t_test_class validator;
|
||||
bool ret = replay_events_through_core<t_test_class>(c, events, validator);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ bool one_block::verify_1(cryptonote::core& c, size_t ev_index, const std::vector
|
|||
//CHECK_TEST_CONDITION(get_block_reward(0) == get_balance(alice, events, chain, mtx));
|
||||
|
||||
// check height
|
||||
std::list<cryptonote::block> blocks;
|
||||
std::vector<cryptonote::block> blocks;
|
||||
std::list<crypto::public_key> outs;
|
||||
bool r = c.get_blocks(0, 100, blocks);
|
||||
//c.get_outs(100, outs);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ bool gen_double_spend_in_different_chains::check_double_spend(cryptonote::core&
|
|||
{
|
||||
DEFINE_TESTS_ERROR_CONTEXT("gen_double_spend_in_different_chains::check_double_spend");
|
||||
|
||||
std::list<block> block_list;
|
||||
std::vector<block> block_list;
|
||||
bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, block_list);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ bool gen_double_spend_base<concrete_test>::check_block_verification_context(cons
|
|||
template<class concrete_test>
|
||||
bool gen_double_spend_base<concrete_test>::mark_last_valid_block(cryptonote::core& c, size_t /*ev_index*/, const std::vector<test_event_entry>& /*events*/)
|
||||
{
|
||||
std::list<cryptonote::block> block_list;
|
||||
std::vector<cryptonote::block> block_list;
|
||||
bool r = c.get_blocks(c.get_current_blockchain_height() - 1, 1, block_list);
|
||||
CHECK_AND_ASSERT_MES(r, false, "core::get_blocks failed");
|
||||
m_last_valid_block = block_list.back();
|
||||
|
|
@ -96,7 +96,7 @@ bool gen_double_spend_base<concrete_test>::check_double_spend(cryptonote::core&
|
|||
}
|
||||
CHECK_NOT_EQ(invalid_index_value, m_invalid_block_index);
|
||||
|
||||
std::list<cryptonote::block> block_list;
|
||||
std::vector<cryptonote::block> block_list;
|
||||
bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, block_list);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
CHECK_TEST_CONDITION(m_last_valid_block == block_list.back());
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ bool gen_ring_signature_1::check_balances_1(cryptonote::core& c, size_t ev_index
|
|||
m_bob_account = boost::get<account_base>(events[3]);
|
||||
m_alice_account = boost::get<account_base>(events[4]);
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ bool gen_ring_signature_1::check_balances_2(cryptonote::core& c, size_t ev_index
|
|||
{
|
||||
DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_1::check_balances_2");
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ bool gen_ring_signature_2::check_balances_1(cryptonote::core& c, size_t ev_index
|
|||
m_bob_account = boost::get<account_base>(events[1]);
|
||||
m_alice_account = boost::get<account_base>(events[2]);
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ bool gen_ring_signature_2::check_balances_2(cryptonote::core& c, size_t ev_index
|
|||
{
|
||||
DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_2::check_balances_2");
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 100 + 2 * CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ bool gen_ring_signature_big::check_balances_1(cryptonote::core& c, size_t ev_ind
|
|||
m_bob_account = boost::get<account_base>(events[1]);
|
||||
m_alice_account = boost::get<account_base>(events[1 + m_test_size]);
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 2 * m_test_size + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ bool gen_ring_signature_big::check_balances_2(cryptonote::core& c, size_t ev_ind
|
|||
{
|
||||
DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_big::check_balances_2");
|
||||
|
||||
std::list<block> blocks;
|
||||
std::vector<block> blocks;
|
||||
bool r = c.get_blocks(0, 2 * m_test_size + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, blocks);
|
||||
CHECK_TEST_CONDITION(r);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue