moneroexamples 7 years ago
parent 35db6a00ca
commit bf39420c8a

@ -55,6 +55,7 @@ Alternative block explorers:
- [http://moneroblocks.info](http://moneroblocks.info/) - [http://moneroblocks.info](http://moneroblocks.info/)
- [https://monerobase.com](https://monerobase.com/) - [https://monerobase.com](https://monerobase.com/)
- [https://monerovision.com](https://monerovision.com)
- [http://chainradar.com](http://chainradar.com/xmr/blocks) - [http://chainradar.com](http://chainradar.com/xmr/blocks)

@ -158,7 +158,7 @@ main(int ac, const char* av[])
// initialize mcore and core_storage // initialize mcore and core_storage
if (!xmreg::init_blockchain(blockchain_path.string(), if (!xmreg::init_blockchain(blockchain_path.string(),
mcore, core_storage)) mcore, core_storage, nettype))
{ {
cerr << "Error accessing blockchain." << endl; cerr << "Error accessing blockchain." << endl;
return EXIT_FAILURE; return EXIT_FAILURE;

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

@ -33,11 +33,13 @@ namespace xmreg
hw::device* m_device; hw::device* m_device;
network_type nettype;
public: public:
MicroCore(); MicroCore();
bool bool
init(const string& _blockchain_path); init(const string& _blockchain_path, network_type nt);
Blockchain& Blockchain&
get_core(); get_core();
@ -77,11 +79,11 @@ namespace xmreg
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);
} }

Loading…
Cancel
Save