aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-09 18:07:44 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-08-09 18:07:44 +0100
commit275894cdefeb80095b4b3463ec732c6e728f91b9 (patch)
tree7667f4d4d05e795ca1696a541c8d6fd252c69112 /src/blockchain_db
parentMerge pull request #358 (diff)
downloadmonero-275894cdefeb80095b4b3463ec732c6e728f91b9.tar.xz
blockchain: always select random outs using triangular distribution
It was only used by the older blockchain_storage. We also move the code to the calling blockchain level, to avoid replicating the code in every DB implementation. This also makes the get_random_out method obsolete, and we delete it.
Diffstat (limited to '')
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.cpp13
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.h2
-rw-r--r--src/blockchain_db/blockchain_db.h4
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp13
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
5 files changed, 0 insertions, 34 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp
index ad3febbd1..a990d7aaf 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.cpp
+++ b/src/blockchain_db/berkeleydb/db_bdb.cpp
@@ -1264,19 +1264,6 @@ uint64_t BlockchainBDB::get_tx_block_height(const crypto::hash& h) const
return (uint64_t)result - 1;
}
-//FIXME: make sure the random method used here is appropriate
-uint64_t BlockchainBDB::get_random_output(const uint64_t& amount) const
-{
- LOG_PRINT_L3("BlockchainBDB::" << __func__);
- check_open();
-
- uint64_t num_outputs = get_num_outputs(amount);
- if (num_outputs == 0)
- throw1(OUTPUT_DNE("Attempting to get a random output for an amount, but none exist"));
-
- return crypto::rand<uint64_t>() % num_outputs;
-}
-
uint64_t BlockchainBDB::get_num_outputs(const uint64_t& amount) const
{
LOG_PRINT_L3("BlockchainBDB::" << __func__);
diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h
index 41f4bcb78..f92bbef68 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.h
+++ b/src/blockchain_db/berkeleydb/db_bdb.h
@@ -295,8 +295,6 @@ public:
virtual uint64_t get_tx_block_height(const crypto::hash& h) const;
- virtual uint64_t get_random_output(const uint64_t& amount) const;
-
virtual uint64_t get_num_outputs(const uint64_t& amount) const;
virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index);
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index ff15109b0..25a34fc09 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -104,7 +104,6 @@
* height get_tx_block_height(hash)
*
* Outputs:
- * index get_random_output(amount)
* uint64_t get_num_outputs(amount)
* pub_key get_output_key(amount, index)
* tx_out get_output(tx_hash, index)
@@ -463,9 +462,6 @@ public:
// returns height of block that contains transaction with hash <h>
virtual uint64_t get_tx_block_height(const crypto::hash& h) const = 0;
- // return global output index of a random output of amount <amount>
- virtual uint64_t get_random_output(const uint64_t& amount) const = 0;
-
// returns the total number of outputs of amount <amount>
virtual uint64_t get_num_outputs(const uint64_t& amount) const = 0;
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index dd829f3b0..d231322f6 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1620,19 +1620,6 @@ uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) const
return *(const uint64_t*)result.mv_data;
}
-//FIXME: make sure the random method used here is appropriate
-uint64_t BlockchainLMDB::get_random_output(const uint64_t& amount) const
-{
- LOG_PRINT_L3("BlockchainLMDB::" << __func__);
- check_open();
-
- uint64_t num_outputs = get_num_outputs(amount);
- if (num_outputs == 0)
- throw1(OUTPUT_DNE("Attempting to get a random output for an amount, but none exist"));
-
- return crypto::rand<uint64_t>() % num_outputs;
-}
-
uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index 0facb8713..b4c197803 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -157,8 +157,6 @@ public:
virtual uint64_t get_tx_block_height(const crypto::hash& h) const;
- virtual uint64_t get_random_output(const uint64_t& amount) const;
-
virtual uint64_t get_num_outputs(const uint64_t& amount) const;
virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index);