Merge pull request #517

a3c5ca0 blockchain_db: make the indexing base a BlockchainDB virtual function (moneromooo-monero)
a702118 blockchain_dump: fix output key dump for BDB 1-based indices (moneromooo-monero)
3bf35e1 db_bdb: read 32 bit heights from keys (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2015-12-05 21:57:56 +02:00
commit 7ee0abe5a6
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
5 changed files with 10 additions and 3 deletions

View File

@ -588,7 +588,7 @@ bool BlockchainBDB::for_all_blocks(std::function<bool(uint64_t, const crypto::ha
bdb_cur cur(DB_DEFAULT_TX, m_blocks);
Dbt_copy<uint64_t> k;
Dbt_copy<uint32_t> k;
Dbt_safe v;
bool ret = true;
int result;

View File

@ -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);

View File

@ -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;

View File

@ -256,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
@ -386,7 +387,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 +407,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);

View File

@ -79,6 +79,7 @@ public:
virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) const { return std::vector<transaction>(); }
virtual uint64_t get_tx_block_height(const crypto::hash& h) const { return 0; }
virtual uint64_t get_num_outputs(const uint64_t& amount) const { return 1; }
virtual uint64_t get_indexing_base() const { return 0; }
virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index) { return output_data_t(); }
virtual output_data_t get_output_key(const uint64_t& global_index) const { return output_data_t(); }
virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const { return tx_out_index(); }