aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_utilities/blockchain_dump.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-05 12:40:01 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-05 12:40:01 +0000
commita70211842693f00f81c2374b7999eda9e184efce (patch)
tree5234e17bb4b478a09db7633d3ef3ad4bf560af8d /src/blockchain_utilities/blockchain_dump.cpp
parentdb_bdb: read 32 bit heights from keys (diff)
downloadmonero-a70211842693f00f81c2374b7999eda9e184efce.tar.xz
blockchain_dump: fix output key dump for BDB 1-based indices
Berkeley DB uses 1 based indices for RECNO databases, and the implementation of BlockchainDB for Berkeley DB assumes 1 based indices are passed to the API, whereas the LMDB one assumes 0 based indices. This is all internally consisteny, but since the BDB code stores 1 based indices in the database, external users have to be aware of this, as the indices will be off by one depending on which DB is used.
Diffstat (limited to '')
-rw-r--r--src/blockchain_utilities/blockchain_dump.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/blockchain_utilities/blockchain_dump.cpp b/src/blockchain_utilities/blockchain_dump.cpp
index f3666c72b..6c61cb90e 100644
--- a/src/blockchain_utilities/blockchain_dump.cpp
+++ b/src/blockchain_utilities/blockchain_dump.cpp
@@ -236,16 +236,19 @@ 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
@@ -386,7 +389,7 @@ int main(int argc, char* argv[])
{
try
{
- tx_out_index toi = db->get_output_tx_and_index_from_global(idx);
+ tx_out_index toi = db->get_output_tx_and_index_from_global(idx + base_idx);
start_struct(d, boost::lexical_cast<std::string>(idx));
write_pod(d, "tx_hash", string_tools::pod_to_hex(toi.first));
write_pod(d, "tx_index", string_tools::pod_to_hex(toi.second));
@@ -406,7 +409,7 @@ int main(int argc, char* argv[])
{
try
{
- output_data_t od = db->get_output_key(idx);
+ output_data_t od = db->get_output_key(idx + base_idx);
start_struct(d, boost::lexical_cast<std::string>(idx));
write_pod(d, "pubkey", string_tools::pod_to_hex(od.pubkey));
write_pod(d, "unlock_time", od.unlock_time);