Steps toward multiple dbs available -- working
There will need to be some more refactoring for these changes to be considered complete/correct, but for now it's working. new daemon cli argument "--db-type", works for LMDB and BerkeleyDB. A good deal of refactoring is also present in this commit, namely Blockchain no longer instantiates BlockchainDB, but rather is passed a pointer to an already-instantiated BlockchainDB on init().
This commit is contained in:
@@ -724,13 +724,6 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags)
|
||||
m_open = true;
|
||||
}
|
||||
|
||||
// unused for now, create will happen on open if doesn't exist
|
||||
void BlockchainBDB::create(const std::string& filename)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainBDB::" << __func__);
|
||||
throw DB_CREATE_FAILURE("create() is not implemented for this BlockchainDB, open() will create files if needed.");
|
||||
}
|
||||
|
||||
void BlockchainBDB::close()
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainBDB::" << __func__);
|
||||
|
||||
@@ -95,8 +95,6 @@ public:
|
||||
|
||||
virtual void open(const std::string& filename, const int db_flags);
|
||||
|
||||
virtual void create(const std::string& filename);
|
||||
|
||||
virtual void close();
|
||||
|
||||
virtual void sync();
|
||||
@@ -279,7 +277,6 @@ private:
|
||||
|
||||
Db* m_spent_keys;
|
||||
|
||||
bool m_open;
|
||||
uint64_t m_height;
|
||||
uint64_t m_num_outputs;
|
||||
std::string m_folder;
|
||||
|
||||
@@ -129,6 +129,11 @@ void BlockchainDB::pop_block(block& blk, std::vector<transaction>& txs)
|
||||
}
|
||||
}
|
||||
|
||||
bool BlockchainDB::is_open()
|
||||
{
|
||||
return m_open;
|
||||
}
|
||||
|
||||
void BlockchainDB::remove_transaction(const crypto::hash& tx_hash)
|
||||
{
|
||||
transaction tx = get_tx(tx_hash);
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
*
|
||||
* General:
|
||||
* open()
|
||||
* is_open()
|
||||
* close()
|
||||
* sync()
|
||||
* reset()
|
||||
@@ -328,8 +329,8 @@ public:
|
||||
// open the db at location <filename>, or create it if there isn't one.
|
||||
virtual void open(const std::string& filename, const int db_flags = 0) = 0;
|
||||
|
||||
// make sure implementation has a create function as well
|
||||
virtual void create(const std::string& filename) = 0;
|
||||
// returns true of the db is open/ready, else false
|
||||
bool is_open();
|
||||
|
||||
// close and sync the db
|
||||
virtual void close() = 0;
|
||||
@@ -482,6 +483,7 @@ public:
|
||||
// returns true if key image <img> is present in spent key images storage
|
||||
virtual bool has_key_image(const crypto::key_image& img) const = 0;
|
||||
|
||||
bool m_open;
|
||||
}; // class BlockchainDB
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2015, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are
|
||||
// permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
// conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
// of conditions and the following disclaimer in the documentation and/or other
|
||||
// materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without specific
|
||||
// prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
#pragma once
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
const std::unordered_set<std::string> blockchain_db_types =
|
||||
{ "lmdb"
|
||||
, "berkeley"
|
||||
};
|
||||
|
||||
} // namespace cryptonote
|
||||
@@ -733,13 +733,6 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
|
||||
// from here, init should be finished
|
||||
}
|
||||
|
||||
// unused for now, create will happen on open if doesn't exist
|
||||
void BlockchainLMDB::create(const std::string& filename)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
throw DB_CREATE_FAILURE("create() is not implemented for this BlockchainDB, open() will create files if needed.");
|
||||
}
|
||||
|
||||
void BlockchainLMDB::close()
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#pragma once
|
||||
|
||||
#include "blockchain_db/blockchain_db.h"
|
||||
#include "cryptonote_protocol/blobdatatype.h" // for type blobdata
|
||||
@@ -116,8 +117,6 @@ public:
|
||||
|
||||
virtual void open(const std::string& filename, const int mdb_flags=0);
|
||||
|
||||
virtual void create(const std::string& filename);
|
||||
|
||||
virtual void close();
|
||||
|
||||
virtual void sync();
|
||||
@@ -302,7 +301,6 @@ private:
|
||||
|
||||
MDB_dbi m_spent_keys;
|
||||
|
||||
bool m_open;
|
||||
uint64_t m_height;
|
||||
uint64_t m_num_outputs;
|
||||
std::string m_folder;
|
||||
|
||||
Reference in New Issue
Block a user