aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities/blockchain_ancestry.cpp
diff options
context:
space:
mode:
authorlukas <np-hardass@protonmail.com>2021-11-05 14:35:08 +0100
committerjeffro256 <jeffro256@tutanota.com>2023-06-30 20:27:05 +0200
commitd6f86e58a6f0e489651af044ad872f9d0e798887 (patch)
treecc5706c2026d03a078c2a0c9fd33a8e400a408ba /src/blockchain_utilities/blockchain_ancestry.cpp
parentMerge pull request #8884 (diff)
downloadmonero-d6f86e58a6f0e489651af044ad872f9d0e798887.tar.xz
Avoid nullptr dereference when constructing Blockchain and tx_memory_pool
Diffstat (limited to 'src/blockchain_utilities/blockchain_ancestry.cpp')
-rw-r--r--src/blockchain_utilities/blockchain_ancestry.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/blockchain_utilities/blockchain_ancestry.cpp b/src/blockchain_utilities/blockchain_ancestry.cpp
index 66dd7813b..c226da230 100644
--- a/src/blockchain_utilities/blockchain_ancestry.cpp
+++ b/src/blockchain_utilities/blockchain_ancestry.cpp
@@ -41,6 +41,7 @@
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_db/blockchain_db.h"
+#include "blockchain_and_pool.h"
#include "version.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
@@ -449,9 +450,7 @@ int main(int argc, char* argv[])
// because unlike blockchain_storage constructor, which takes a pointer to
// tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
- std::unique_ptr<Blockchain> core_storage;
- tx_memory_pool m_mempool(*core_storage);
- core_storage.reset(new Blockchain(m_mempool));
+ std::unique_ptr<BlockchainAndPool> core_storage = std::make_unique<BlockchainAndPool>();
BlockchainDB *db = new_db();
if (db == NULL)
{
@@ -472,7 +471,7 @@ int main(int argc, char* argv[])
LOG_PRINT_L0("Error opening database: " << e.what());
return 1;
}
- r = core_storage->init(db, net_type);
+ r = core_storage->blockchain.init(db, net_type);
CHECK_AND_ASSERT_MES(r, 1, "Failed to initialize source blockchain storage");
LOG_PRINT_L0("Source blockchain storage initialized OK");
@@ -716,7 +715,7 @@ int main(int argc, char* argv[])
}
done:
- core_storage->deinit();
+ core_storage->blockchain.deinit();
if (opt_show_cache_stats)
MINFO("cache: txes " << std::to_string(cached_txes*100./total_txes)