blockchain_and_pool: move to crytonote_core and enforce its usage

This commit is contained in:
jeffro256 2023-06-30 14:52:43 -05:00
parent d6f86e58a6
commit ffbf9f4766
No known key found for this signature in database
GPG key ID: 6F79797A6E392442
17 changed files with 64 additions and 90 deletions

View file

@ -143,9 +143,8 @@ namespace
}
static std::unique_ptr<cryptonote::Blockchain> init_blockchain(const std::vector<test_event_entry> & events, cryptonote::network_type nettype)
static std::unique_ptr<cryptonote::BlockchainAndPool> init_blockchain(const std::vector<test_event_entry> & events, cryptonote::network_type nettype)
{
std::unique_ptr<cryptonote::Blockchain> bc;
v_hardforks_t hardforks;
cryptonote::test_options test_options_tmp{nullptr, 0};
const cryptonote::test_options * test_options = &test_options_tmp;
@ -159,10 +158,8 @@ static std::unique_ptr<cryptonote::Blockchain> init_blockchain(const std::vector
test_options_tmp.hard_forks = hardforks.data();
test_options = &test_options_tmp;
cryptonote::tx_memory_pool txpool(*bc);
bc.reset(new cryptonote::Blockchain(txpool));
std::unique_ptr<cryptonote::BlockchainAndPool> bap(new BlockchainAndPool());
cryptonote::Blockchain *blockchain = bc.get();
auto bdb = new TestDB();
BOOST_FOREACH(const test_event_entry &ev, events)
@ -177,9 +174,9 @@ static std::unique_ptr<cryptonote::Blockchain> init_blockchain(const std::vector
bdb->add_block(*blk, 1, 1, 1, 0, 0, blk_hash);
}
bool r = blockchain->init(bdb, nettype, true, test_options, 2, nullptr);
bool r = bap->blockchain.init(bdb, nettype, true, test_options, 2, nullptr);
CHECK_AND_ASSERT_THROW_MES(r, "could not init blockchain from events");
return bc;
return bap;
}
void test_generator::get_block_chain(std::vector<block_info>& blockchain, const crypto::hash& head, size_t n) const
@ -393,7 +390,7 @@ bool test_generator::construct_block_manually_tx(cryptonote::block& blk, const c
void test_generator::fill_nonce(cryptonote::block& blk, const difficulty_type& diffic, uint64_t height)
{
const cryptonote::Blockchain *blockchain = nullptr;
std::unique_ptr<cryptonote::Blockchain> bc;
std::unique_ptr<cryptonote::BlockchainAndPool> bap;
if (blk.major_version >= RX_BLOCK_VERSION && diffic > 1)
{
@ -403,8 +400,8 @@ void test_generator::fill_nonce(cryptonote::block& blk, const difficulty_type& d
}
else
{
bc = init_blockchain(*m_events, m_nettype);
blockchain = bc.get();
bap = init_blockchain(*m_events, m_nettype);
blockchain = &bap->blockchain;
}
}