blockchain_db: make the indexing base a BlockchainDB virtual function
This commit is contained in:
parent
a702118426
commit
a3c5ca077c
|
@ -297,6 +297,8 @@ public:
|
||||||
|
|
||||||
virtual uint64_t get_num_outputs(const uint64_t& amount) const;
|
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& amount, const uint64_t& index);
|
||||||
virtual output_data_t get_output_key(const uint64_t& global_index) const;
|
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);
|
virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs);
|
||||||
|
|
|
@ -464,6 +464,9 @@ public:
|
||||||
// returns the total number of outputs of amount <amount>
|
// returns the total number of outputs of amount <amount>
|
||||||
virtual uint64_t get_num_outputs(const uint64_t& amount) const = 0;
|
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>
|
// 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& amount, const uint64_t& index) = 0;
|
||||||
virtual output_data_t get_output_key(const uint64_t& global_index) const = 0;
|
virtual output_data_t get_output_key(const uint64_t& global_index) const = 0;
|
||||||
|
|
|
@ -236,19 +236,16 @@ int main(int argc, char* argv[])
|
||||||
BlockchainDB* db;
|
BlockchainDB* db;
|
||||||
int mdb_flags = 0;
|
int mdb_flags = 0;
|
||||||
std::string db_type = command_line::get_arg(vm, arg_db_type);
|
std::string db_type = command_line::get_arg(vm, arg_db_type);
|
||||||
size_t base_idx = 0;
|
|
||||||
if (db_type.empty() || db_type == "lmdb")
|
if (db_type.empty() || db_type == "lmdb")
|
||||||
{
|
{
|
||||||
db = new BlockchainLMDB();
|
db = new BlockchainLMDB();
|
||||||
mdb_flags |= MDB_RDONLY;
|
mdb_flags |= MDB_RDONLY;
|
||||||
base_idx = 0;
|
|
||||||
}
|
}
|
||||||
#ifdef BERKELEY_DB
|
#ifdef BERKELEY_DB
|
||||||
else if (db_type == "berkeley")
|
else if (db_type == "berkeley")
|
||||||
{
|
{
|
||||||
db = new BlockchainBDB();
|
db = new BlockchainBDB();
|
||||||
// can't open readonly due to the way flags are split in db_bdb.cpp
|
// can't open readonly due to the way flags are split in db_bdb.cpp
|
||||||
base_idx = 1;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
@ -259,6 +256,7 @@ int main(int argc, char* argv[])
|
||||||
boost::filesystem::path folder(m_config_folder);
|
boost::filesystem::path folder(m_config_folder);
|
||||||
folder /= db->get_db_name();
|
folder /= db->get_db_name();
|
||||||
const std::string filename = folder.string();
|
const std::string filename = folder.string();
|
||||||
|
uint64_t base_idx = db->get_indexing_base();
|
||||||
|
|
||||||
LOG_PRINT_L0("Loading blockchain from folder " << filename << " ...");
|
LOG_PRINT_L0("Loading blockchain from folder " << filename << " ...");
|
||||||
try
|
try
|
||||||
|
|
|
@ -79,6 +79,7 @@ public:
|
||||||
virtual std::vector<transaction> get_tx_list(const std::vector<crypto::hash>& hlist) const { return std::vector<transaction>(); }
|
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_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_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& 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 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(); }
|
virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const { return tx_out_index(); }
|
||||||
|
|
Loading…
Reference in New Issue