diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-05 18:41:29 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-12-05 18:41:29 +0000 |
commit | a3c5ca077c27b7a8fe5ee0a7afdc1d30b6f8ffe8 (patch) | |
tree | 3e742a2c53b35620d28b9003a6788e80a8651024 /src | |
parent | blockchain_dump: fix output key dump for BDB 1-based indices (diff) | |
download | monero-a3c5ca077c27b7a8fe5ee0a7afdc1d30b6f8ffe8.tar.xz |
blockchain_db: make the indexing base a BlockchainDB virtual function
Diffstat (limited to 'src')
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.h | 2 | ||||
-rw-r--r-- | src/blockchain_db/blockchain_db.h | 3 | ||||
-rw-r--r-- | src/blockchain_utilities/blockchain_dump.cpp | 4 |
3 files changed, 6 insertions, 3 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index 6bc9cb4f1..d05abea25 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -297,6 +297,8 @@ public: virtual uint64_t get_num_outputs(const uint64_t& amount) const; + virtual uint64_t get_indexing_base() const { return 1; } + virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index); virtual output_data_t get_output_key(const uint64_t& global_index) const; virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs); diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 85144f04c..152f29b38 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -464,6 +464,9 @@ public: // returns the total number of outputs of amount <amount> virtual uint64_t get_num_outputs(const uint64_t& amount) const = 0; + // return index of the first element (should be hidden, but isn't) + virtual uint64_t get_indexing_base() const { return 0; } + // return public key for output with global output amount <amount> and index <index> virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index) = 0; virtual output_data_t get_output_key(const uint64_t& global_index) const = 0; diff --git a/src/blockchain_utilities/blockchain_dump.cpp b/src/blockchain_utilities/blockchain_dump.cpp index 6c61cb90e..f5f0986ec 100644 --- a/src/blockchain_utilities/blockchain_dump.cpp +++ b/src/blockchain_utilities/blockchain_dump.cpp @@ -236,19 +236,16 @@ int main(int argc, char* argv[]) BlockchainDB* db; int mdb_flags = 0; std::string db_type = command_line::get_arg(vm, arg_db_type); - size_t base_idx = 0; if (db_type.empty() || db_type == "lmdb") { db = new BlockchainLMDB(); mdb_flags |= MDB_RDONLY; - base_idx = 0; } #ifdef BERKELEY_DB else if (db_type == "berkeley") { db = new BlockchainBDB(); // can't open readonly due to the way flags are split in db_bdb.cpp - base_idx = 1; } #endif else @@ -259,6 +256,7 @@ int main(int argc, char* argv[]) boost::filesystem::path folder(m_config_folder); folder /= db->get_db_name(); const std::string filename = folder.string(); + uint64_t base_idx = db->get_indexing_base(); LOG_PRINT_L0("Loading blockchain from folder " << filename << " ..."); try |