|
|
|
@ -45,31 +45,20 @@ MicroCore::MicroCore():
|
|
|
|
|
* Initialize m_blockchain_storage with the BlockchainLMDB object.
|
|
|
|
|
*/
|
|
|
|
|
bool
|
|
|
|
|
MicroCore::init(const string& _blockchain_path)
|
|
|
|
|
MicroCore::init(const string& _blockchain_path, network_type nt)
|
|
|
|
|
{
|
|
|
|
|
int db_flags = 0;
|
|
|
|
|
|
|
|
|
|
blockchain_path = _blockchain_path;
|
|
|
|
|
|
|
|
|
|
//db_flags |= MDB_RDONLY;
|
|
|
|
|
db_flags |= MDB_NOLOCK;
|
|
|
|
|
//db_flags |= MDB_SYNC;
|
|
|
|
|
|
|
|
|
|
// uint64_t DEFAULT_FLAGS = MDB_NOMETASYNC | MDB_NORDAHEAD;
|
|
|
|
|
|
|
|
|
|
//db_flags = DEFAULT_FLAGS;
|
|
|
|
|
nettype = nt;
|
|
|
|
|
|
|
|
|
|
HardFork* m_hardfork = nullptr;
|
|
|
|
|
db_flags |= MDB_RDONLY;
|
|
|
|
|
db_flags |= MDB_NOLOCK;
|
|
|
|
|
|
|
|
|
|
BlockchainDB* db = nullptr;
|
|
|
|
|
db = new BlockchainLMDB();
|
|
|
|
|
|
|
|
|
|
bool use_testnet {false};
|
|
|
|
|
|
|
|
|
|
uint64_t hard_fork_version_1_till = use_testnet ? testnet_hard_fork_version_1_till : mainnet_hard_fork_version_1_till;
|
|
|
|
|
|
|
|
|
|
m_hardfork = new HardFork(*db, 1, hard_fork_version_1_till);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// try opening lmdb database files
|
|
|
|
@ -84,13 +73,11 @@ MicroCore::init(const string& _blockchain_path)
|
|
|
|
|
// check if the blockchain database
|
|
|
|
|
// is successful opened
|
|
|
|
|
if(!db->is_open())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// initialize Blockchain object to manage
|
|
|
|
|
// the database.
|
|
|
|
|
return m_blockchain_storage.init(db, m_hardfork, network_type::MAINNET);
|
|
|
|
|
return m_blockchain_storage.init(db, nettype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -337,11 +324,12 @@ MicroCore::~MicroCore()
|
|
|
|
|
bool
|
|
|
|
|
init_blockchain(const string& path,
|
|
|
|
|
MicroCore& mcore,
|
|
|
|
|
Blockchain*& core_storage)
|
|
|
|
|
Blockchain*& core_storage,
|
|
|
|
|
network_type nt)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// initialize the core using the blockchain path
|
|
|
|
|
if (!mcore.init(path))
|
|
|
|
|
if (!mcore.init(path, nt))
|
|
|
|
|
{
|
|
|
|
|
cerr << "Error accessing blockchain." << endl;
|
|
|
|
|
return false;
|
|
|
|
|