get_alt_blocks added

master
moneroexamples 8 years ago
parent 2fd1a05aa8
commit a057da13f6

@ -425,18 +425,15 @@ namespace xmreg
{"show_cache_times" , show_cache_times} {"show_cache_times" , show_cache_times}
}; };
std::list<block> atl_blks; vector<block_complete_entry> atl_blks;
if (core_storage->get_alternative_blocks(atl_blks)) rpc.get_alt_blocks(atl_blks);
{
for (const block& alt_blk: atl_blks) cout << "atl_blks.size(): " << atl_blks.size() << endl;
{
cout << "alt_blk tx: " << alt_blk.tx_hashes.size() << endl; for (const block_complete_entry& alt_blk: atl_blks)
}
}
else
{ {
cerr << "get_alternative_blocks(atl_blks) returned false" << endl; cout << "alt_blk tx: " << alt_blk.txs.size() << endl;
} }
context.emplace("txs", mstch::array()); // will keep tx to show context.emplace("txs", mstch::array()); // will keep tx to show

@ -208,6 +208,60 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
return true; return true;
} }
bool
rpccalls::get_alt_blocks(vector<block_complete_entry>& alt_blocks)
{
bool r {false};
COMMAND_RPC_GET_ALT_BLOCKS::request req;
COMMAND_RPC_GET_ALT_BLOCKS::response resp;
{
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon())
{
cerr << "get_mempool: not connected to deamon" << endl;
return false;
}
r = epee::net_utils::invoke_http_bin("/getaltblocks.bin",
req, resp,
m_http_client);
}
string err;
if (r)
{
if (resp.status == CORE_RPC_STATUS_BUSY)
{
err = "daemon is busy. Please try again later.";
}
else if (resp.status != CORE_RPC_STATUS_OK)
{
err = "daemon rpc failed. Please try again later.";
}
if (!err.empty())
{
cerr << "Error connecting to Monero deamon due to "
<< err << endl;
return false;
}
}
else
{
cerr << "Error connecting to Monero deamon at "
<< deamon_url << endl;
return false;
}
alt_blocks = resp.blocks;
return true;
}
bool bool
rpccalls::get_dynamic_per_kb_fee_estimate( rpccalls::get_dynamic_per_kb_fee_estimate(

@ -52,6 +52,9 @@ public:
bool bool
get_network_info(COMMAND_RPC_GET_INFO::response& info); get_network_info(COMMAND_RPC_GET_INFO::response& info);
bool
get_alt_blocks(vector<block_complete_entry>& alt_blocks);
bool bool
get_dynamic_per_kb_fee_estimate( get_dynamic_per_kb_fee_estimate(
uint64_t grace_blocks, uint64_t grace_blocks,

Loading…
Cancel
Save