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