get_txs_in_blocks tested

pull/93/merge
moneroexamples 6 years ago
parent 732b3307a1
commit ae3c3fcd38

@ -34,7 +34,7 @@
"wallet_import" :
{
"_comment": "if fee is 0, then importing is free. fee is in base 1e12, e.g., 0.1 xmr is 0.1 x 1e12 = 100000000000",
"fee" : 100000000000,
"fee" : 0,
"testnet" :
{
"address" : "9tzmPMTViHYM3z6NAgQni1Qm1Emzxy5hQFibPgWD3LVTAz91yok5Eni1pH6zKhBHzpTU15GZooPHSGHXFvFuXEdmEG2sWAZ",

@ -16,6 +16,7 @@ var config = {
subAddressPrefix: 42,
addressPrefixTestnet: 53,
integratedAddressPrefixTestnet: 54,
subAddressPrefixTestnet: 63,
addressPrefixStagenet: 24,
integratedAddressPrefixStagenet: 25,

@ -22,7 +22,7 @@ main(int ac, const char* av[])
// get command line options
xmreg::CmdLineOptions opts {ac, av};
auto help_opt = opts.get_option<bool>("help");
auto help_opt = opts.get_option<bool>("help");
// if help was chosen, display help text and finish
if (*help_opt)

@ -112,6 +112,25 @@ MicroCore::get_block_from_height(uint64_t height, block& blk) const
}
bool
MicroCore::get_block_complete_entry(block const& b, block_complete_entry& bce)
{
bce.block = cryptonote::block_to_blob(b);
for (const auto &tx_hash: b.tx_hashes)
{
transaction tx;
if (!get_tx(tx_hash, tx))
return false;
cryptonote::blobdata txblob = tx_to_blob(tx);
bce.txs.push_back(txblob);
}
return true;
}
bool
MicroCore::get_tx(crypto::hash const& tx_hash, transaction& tx) const

@ -122,7 +122,6 @@ public:
return core_storage.get_db().get_tx_amount_output_indices(tx_id);
}
virtual bool
get_mempool_txs(
std::vector<tx_info>& tx_infos,
@ -159,6 +158,9 @@ public:
return core_storage.get_dynamic_per_kb_fee_estimate(grace_blocks);
}
bool
get_block_complete_entry(block const& b, block_complete_entry& bce);
virtual bool
get_block_from_height(uint64_t height, block& blk) const;

@ -1362,5 +1362,80 @@ hex_to_tx_blob(string const& tx_hex)
return tx_blob;
}
bool
hex_to_complete_block(string const& cblk_str,
block_complete_entry& cblk)
{
cryptonote::blobdata cblk_blob;
if (!epee::string_tools::parse_hexstr_to_binbuff(
cblk_str, cblk_blob))
return false;
if (!epee::serialization::load_t_from_binary(cblk, cblk_blob))
return false;
return true;
}
bool
hex_to_complete_block(vector<string> const& cblks_str,
vector<block_complete_entry>& cblks)
{
for (auto const& cblk_str: cblks_str)
{
block_complete_entry cblk;
if (!hex_to_complete_block(cblk_str, cblk))
return false;
cblks.push_back(cblk);
}
return true;
}
bool
blocks_and_txs_from_complete_blocks(
vector<block_complete_entry> const& cblks,
vector<block>& blocks,
vector<transaction>& transactions)
{
for (auto const& cblk: cblks)
{
block blk;
if (!parse_and_validate_block_from_blob(cblk.block, blk))
return false;
blocks.push_back(blk);
// first is miner_tx
transactions.push_back(blk.miner_tx);
vector<transaction> txs;
for (auto const& tx_blob: cblk.txs)
{
transaction tx;
if (!parse_and_validate_tx_from_blob(tx_blob, tx))
return false;
txs.push_back(tx);
}
// now normal txs
transactions.insert(transactions.end(),
txs.begin(), txs.end());
}
return true;
}
}

@ -275,6 +275,19 @@ tx_to_hex(transaction const& tx);
string
hex_to_tx_blob(string const& tx_hex);
bool
hex_to_complete_block(string const& cblk_str,
block_complete_entry& cblk);
bool
hex_to_complete_block(vector<string> const& cblks_str,
vector<block_complete_entry> & cblks);
bool
blocks_and_txs_from_complete_blocks(
vector<block_complete_entry> const& cblks,
vector<block>& blocks,
vector<transaction>& txs);
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save