xmreg::init_blockchain added
This commit is contained in:
parent
ca2e97e8dc
commit
38a77c6cbf
18
main.cpp
18
main.cpp
|
@ -17,39 +17,31 @@ namespace epee {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
path blockchain_path {"/home/mwo/.bitmonero/lmdb"};
|
path blockchain_path {"/home/mwo/.bitmonero/lmdb"};
|
||||||
|
|
||||||
fmt::print("Blockchain path : {}\n", blockchain_path);
|
|
||||||
|
|
||||||
// enable basic monero log output
|
// enable basic monero log output
|
||||||
xmreg::enable_monero_log();
|
xmreg::enable_monero_log();
|
||||||
|
|
||||||
// create instance of our MicroCore
|
// create instance of our MicroCore
|
||||||
xmreg::MicroCore mcore;
|
xmreg::MicroCore mcore;
|
||||||
|
cryptonote::Blockchain* core_storage;
|
||||||
|
|
||||||
// initialize the core using the blockchain path
|
if (!xmreg::init_blockchain(blockchain_path.string(),
|
||||||
if (!mcore.init(blockchain_path.string()))
|
mcore, core_storage))
|
||||||
{
|
{
|
||||||
cerr << "Error accessing blockchain." << endl;
|
cerr << "Error accessing blockchain." << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the high level cryptonote::Blockchain object to interact
|
|
||||||
// with the blockchain lmdb database
|
|
||||||
cryptonote::Blockchain& core_storage = mcore.get_core();
|
|
||||||
|
|
||||||
|
// get the current blockchain height. Just to check if it reads ok.
|
||||||
// get the current blockchain height. Just to check
|
uint64_t height = core_storage->get_current_blockchain_height() - 1;
|
||||||
// if it reads ok.
|
|
||||||
uint64_t height = core_storage.get_current_blockchain_height() - 1;
|
|
||||||
|
|
||||||
fmt::print("\n\n"
|
fmt::print("\n\n"
|
||||||
"Top block height : {:d}\n", height);
|
"Top block height : {:d}\n", height);
|
||||||
|
|
||||||
|
|
||||||
std::string view {"Blockchain height {{height}}"};
|
std::string view {"Blockchain height {{height}}"};
|
||||||
|
|
||||||
mstch::map context {
|
mstch::map context {
|
||||||
|
|
|
@ -36,8 +36,8 @@ namespace xmreg
|
||||||
{
|
{
|
||||||
int db_flags = 0;
|
int db_flags = 0;
|
||||||
|
|
||||||
db_flags |= MDB_RDONLY;
|
//db_flags |= MDB_RDONLY;
|
||||||
db_flags |= MDB_NOLOCK;
|
//db_flags |= MDB_NOLOCK;
|
||||||
db_flags |= MDB_NOSYNC;
|
db_flags |= MDB_NOSYNC;
|
||||||
|
|
||||||
BlockchainDB* db = nullptr;
|
BlockchainDB* db = nullptr;
|
||||||
|
@ -273,4 +273,27 @@ namespace xmreg
|
||||||
{
|
{
|
||||||
delete &m_blockchain_storage.get_db();
|
delete &m_blockchain_storage.get_db();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
init_blockchain(const string& path,
|
||||||
|
MicroCore& mcore,
|
||||||
|
Blockchain*& core_storage)
|
||||||
|
{
|
||||||
|
|
||||||
|
// initialize the core using the blockchain path
|
||||||
|
if (!mcore.init(path))
|
||||||
|
{
|
||||||
|
cerr << "Error accessing blockchain." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the high level Blockchain object to interact
|
||||||
|
// with the blockchain lmdb database
|
||||||
|
core_storage = &(mcore.get_core());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -65,6 +65,15 @@ namespace xmreg
|
||||||
virtual ~MicroCore();
|
virtual ~MicroCore();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
init_blockchain(const string& path,
|
||||||
|
MicroCore& mcore,
|
||||||
|
Blockchain*& core_storage);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,6 @@ namespace xmreg
|
||||||
array<size_t, 5>
|
array<size_t, 5>
|
||||||
timestamp_difference(uint64_t t1, uint64_t t2);
|
timestamp_difference(uint64_t t1, uint64_t t2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //XMREG01_TOOLS_H
|
#endif //XMREG01_TOOLS_H
|
||||||
|
|
|
@ -60,7 +60,6 @@ namespace xmreg
|
||||||
get_encrypted_payment_id(const transaction& tx,
|
get_encrypted_payment_id(const transaction& tx,
|
||||||
crypto::hash8& payment_id);
|
crypto::hash8& payment_id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
Loading…
Reference in New Issue