aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities/blockchain_prune.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2023-08-17 10:21:40 -0500
committerluigi1111 <luigi1111w@gmail.com>2023-08-17 10:21:40 -0500
commit6fc67869a16e92aa2e7b291f8948f6807557a6b5 (patch)
treebd3032d01cb3c126504fc478e02a351ae37dfd94 /src/blockchain_utilities/blockchain_prune.cpp
parentMerge pull request #8914 (diff)
parentblockchain_and_pool: move to crytonote_core and enforce its usage (diff)
downloadmonero-6fc67869a16e92aa2e7b291f8948f6807557a6b5.tar.xz
Merge pull request #8924
ffbf9f4 blockchain_and_pool: move to crytonote_core and enforce its usage (jeffro256) d6f86e5 Avoid nullptr dereference when constructing Blockchain and tx_memory_pool (lukas)
Diffstat (limited to 'src/blockchain_utilities/blockchain_prune.cpp')
-rw-r--r--src/blockchain_utilities/blockchain_prune.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/blockchain_utilities/blockchain_prune.cpp b/src/blockchain_utilities/blockchain_prune.cpp
index 1e4b48b73..1a9618617 100644
--- a/src/blockchain_utilities/blockchain_prune.cpp
+++ b/src/blockchain_utilities/blockchain_prune.cpp
@@ -35,8 +35,6 @@
#include "common/command_line.h"
#include "common/pruning.h"
#include "cryptonote_core/cryptonote_core.h"
-#include "cryptonote_core/blockchain.h"
-#include "blockchain_db/blockchain_db.h"
#include "blockchain_db/lmdb/db_lmdb.h"
#include "version.h"
@@ -562,22 +560,15 @@ int main(int argc, char* argv[])
// Use Blockchain instead of lower-level BlockchainDB for two reasons:
// 1. Blockchain has the init() method for easy setup
// 2. exporter needs to use get_current_blockchain_height(), get_block_id_by_height(), get_block_by_hash()
- //
- // cannot match blockchain_storage setup above with just one line,
- // e.g.
- // Blockchain* core_storage = new Blockchain(NULL);
- // because unlike blockchain_storage constructor, which takes a pointer to
- // tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
MINFO("Initializing source blockchain (BlockchainDB)");
- std::array<std::unique_ptr<Blockchain>, 2> core_storage;
- Blockchain *blockchain = NULL;
- tx_memory_pool m_mempool(*blockchain);
+ std::array<std::unique_ptr<BlockchainAndPool>, 2> core_storage{
+ std::make_unique<BlockchainAndPool>(),
+ std::make_unique<BlockchainAndPool>()};
+
boost::filesystem::path paths[2];
bool already_pruned = false;
for (size_t n = 0; n < core_storage.size(); ++n)
{
- core_storage[n].reset(new Blockchain(m_mempool));
-
BlockchainDB* db = new_db();
if (db == NULL)
{
@@ -622,12 +613,12 @@ int main(int argc, char* argv[])
MERROR("Error opening database: " << e.what());
return 1;
}
- r = core_storage[n]->init(db, net_type);
+ r = core_storage[n]->blockchain.init(db, net_type);
std::string source_dest = n == 0 ? "source" : "pruned";
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize " << source_dest << " blockchain storage");
MINFO(source_dest << " blockchain storage initialized OK");
- if (n == 0 && core_storage[0]->get_blockchain_pruning_seed())
+ if (n == 0 && core_storage[0]->blockchain.get_blockchain_pruning_seed())
{
if (!opt_copy_pruned_database)
{
@@ -637,9 +628,9 @@ int main(int argc, char* argv[])
already_pruned = true;
}
}
- core_storage[0]->deinit();
+ core_storage[0]->blockchain.deinit();
core_storage[0].reset(NULL);
- core_storage[1]->deinit();
+ core_storage[1]->blockchain.deinit();
core_storage[1].reset(NULL);
MINFO("Pruning...");