Electroneum
Public Member Functions | Private Attributes | List of all members
etneg::MicroCore Class Reference

#include <MicroCore.h>

Collaboration diagram for etneg::MicroCore:
Collaboration graph
[legend]

Public Member Functions

 MicroCore ()
 
bool init (const string &_blockchain_path, bool testnet=false)
 
Blockchainget_core ()
 
bool get_block_by_height (const uint64_t &height, block &blk)
 
bool get_tx (const crypto::hash &tx_hash, transaction &tx)
 
bool get_tx (const string &tx_hash, transaction &tx)
 
bool find_output_in_tx (const transaction &tx, const public_key &output_pubkey, tx_out &out, size_t &output_index)
 
bool get_tx_hash_from_output_pubkey (const public_key &output_pubkey, const uint64_t &block_height, crypto::hash &tx_hash, transaction &tx_found)
 
uint64_t get_blk_timestamp (uint64_t blk_height)
 
string get_blkchain_path ()
 
virtual ~MicroCore ()
 

Private Attributes

string blockchain_path
 
tx_memory_pool m_mempool
 
Blockchain m_blockchain_storage
 

Detailed Description

Micro version of cryptonode::core class Micro version of constructor, init and destructor are implemted.

Just enough to read the blockchain database for use in the example.

Constructor & Destructor Documentation

◆ MicroCore()

etneg::MicroCore::MicroCore ( )

The constructor is interesting, as m_mempool and m_blockchain_storage depend on each other.

So basically m_mempool is initialized with reference to Blockchain (i.e., Blockchain&) and m_blockchain_storage is initialized with reference to m_mempool (i.e., tx_memory_pool&)

The same is done in cryptonode::core.

◆ ~MicroCore()

etneg::MicroCore::~MicroCore ( )
virtual

De-initialized Blockchain.

since blockchain is opened as MDB_RDONLY need to manually free memory taken on heap by BlockchainLMDB

Member Function Documentation

◆ find_output_in_tx()

bool etneg::MicroCore::find_output_in_tx ( const transaction tx,
const public_key &  output_pubkey,
tx_out out,
size_t &  output_index 
)

Find output with given public key in a given transaction

◆ get_blk_timestamp()

uint64_t etneg::MicroCore::get_blk_timestamp ( uint64_t  blk_height)

◆ get_blkchain_path()

string etneg::MicroCore::get_blkchain_path ( )

◆ get_block_by_height()

bool etneg::MicroCore::get_block_by_height ( const uint64_t &  height,
block blk 
)

Get block by its height

returns true if success

◆ get_core()

Blockchain & etneg::MicroCore::get_core ( )

Get m_blockchain_storage. Initialize m_blockchain_storage with the BlockchainLMDB object.

◆ get_tx() [1/2]

bool etneg::MicroCore::get_tx ( const crypto::hash tx_hash,
transaction tx 
)

Get transaction tx from the blockchain using it hash

◆ get_tx() [2/2]

bool etneg::MicroCore::get_tx ( const string &  tx_hash,
transaction tx 
)

◆ get_tx_hash_from_output_pubkey()

bool etneg::MicroCore::get_tx_hash_from_output_pubkey ( const public_key &  output_pubkey,
const uint64_t &  block_height,
crypto::hash tx_hash,
cryptonote::transaction tx_found 
)

Returns tx hash in a given block which contains given output's public key

◆ init()

bool etneg::MicroCore::init ( const string &  _blockchain_path,
bool  testnet = false 
)

Initialized the MicroCore object.

Create BlockchainLMDB on the heap. Open database files located in blockchain_path. Initialize m_blockchain_storage with the BlockchainLMDB object.

Member Data Documentation

◆ blockchain_path

string etneg::MicroCore::blockchain_path
private

◆ m_blockchain_storage

Blockchain etneg::MicroCore::m_blockchain_storage
private

◆ m_mempool

tx_memory_pool etneg::MicroCore::m_mempool
private

The documentation for this class was generated from the following files: