From 3bf35e14e3b9a21e4a2b5fbb1dd27ca5b6b8a6f1 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 4 Dec 2015 22:25:00 +0000 Subject: db_bdb: read 32 bit heights from keys Keys in Berkeley DB are 32 bits. We don't want to read random bits in the high part. --- src/blockchain_db/berkeleydb/db_bdb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/blockchain_db') diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index da68ff40c..486b63a3e 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -588,7 +588,7 @@ bool BlockchainBDB::for_all_blocks(std::function k; + Dbt_copy k; Dbt_safe v; bool ret = true; int result; -- cgit v1.2.3 From a3c5ca077c27b7a8fe5ee0a7afdc1d30b6f8ffe8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 5 Dec 2015 18:41:29 +0000 Subject: blockchain_db: make the indexing base a BlockchainDB virtual function --- src/blockchain_db/berkeleydb/db_bdb.h | 2 ++ src/blockchain_db/blockchain_db.h | 3 +++ 2 files changed, 5 insertions(+) (limited to 'src/blockchain_db') 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 &offsets, std::vector &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 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 and 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; -- cgit v1.2.3