mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 16:27:39 +00:00
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.
This commit is contained in:
parent
3bf35e14e3
commit
a702118426
1 changed files with 5 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue