mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Merge pull request #1204
7db29d6
print_coinbase_tx_sum now breaks output into fee and emission components (Dion Ahmetaj)dd6c443
changed params from start/end index to height/count (Dion Ahmetaj)e95d3f3
attempted to remove whitespace spam (Dion Ahmetaj)412da63
added print_coinbase_tx_sum option (Dion Ahmetaj)
This commit is contained in:
commit
3db0ebafe5
11 changed files with 139 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -103,3 +103,4 @@ local.properties
|
||||||
.texlipse
|
.texlipse
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
/testnet
|
|
@ -616,6 +616,34 @@ namespace cryptonote
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
std::pair<uint64_t, uint64_t> core::get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count)
|
||||||
|
{
|
||||||
|
std::list<block> blocks;
|
||||||
|
std::list<transaction> txs;
|
||||||
|
std::list<crypto::hash> missed_txs;
|
||||||
|
uint64_t coinbase_amount = 0;
|
||||||
|
uint64_t emission_amount = 0;
|
||||||
|
uint64_t total_fee_amount = 0;
|
||||||
|
uint64_t tx_fee_amount = 0;
|
||||||
|
this->get_blocks(start_offset, count, blocks);
|
||||||
|
BOOST_FOREACH(auto& b, blocks)
|
||||||
|
{
|
||||||
|
coinbase_amount = get_outs_money_amount(b.miner_tx);
|
||||||
|
this->get_transactions(b.tx_hashes, txs, missed_txs);
|
||||||
|
BOOST_FOREACH(const auto& tx, txs)
|
||||||
|
{
|
||||||
|
tx_fee_amount += get_tx_fee(tx);
|
||||||
|
}
|
||||||
|
|
||||||
|
emission_amount += coinbase_amount - tx_fee_amount;
|
||||||
|
total_fee_amount += tx_fee_amount;
|
||||||
|
coinbase_amount = 0;
|
||||||
|
tx_fee_amount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::pair<uint64_t, uint64_t>(emission_amount, total_fee_amount);
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const
|
bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const
|
||||||
{
|
{
|
||||||
std::unordered_set<crypto::key_image> ki;
|
std::unordered_set<crypto::key_image> ki;
|
||||||
|
|
|
@ -600,6 +600,13 @@ namespace cryptonote
|
||||||
*/
|
*/
|
||||||
size_t get_block_sync_size() const { return block_sync_size; }
|
size_t get_block_sync_size() const { return block_sync_size; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get the sum of coinbase tx amounts between blocks
|
||||||
|
*
|
||||||
|
* @return the number of blocks to sync in one go
|
||||||
|
*/
|
||||||
|
std::pair<uint64_t, uint64_t> get_coinbase_tx_sum(const uint64_t start_offset, const uint64_t count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -452,5 +452,27 @@ bool t_command_parser_executor::output_histogram(const std::vector<std::string>&
|
||||||
return m_executor.output_histogram(min_count, max_count);
|
return m_executor.output_histogram(min_count, max_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector<std::string>& args)
|
||||||
|
{
|
||||||
|
if(!args.size())
|
||||||
|
{
|
||||||
|
std::cout << "need block height parameter" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uint64_t height = 0;
|
||||||
|
uint64_t count = 0;
|
||||||
|
if(!epee::string_tools::get_xtype_from_string(height, args[0]))
|
||||||
|
{
|
||||||
|
std::cout << "wrong starter block height parameter" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1]))
|
||||||
|
{
|
||||||
|
std::cout << "wrong count parameter" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_executor.print_coinbase_tx_sum(height, count);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace daemonize
|
} // namespace daemonize
|
||||||
|
|
|
@ -115,6 +115,8 @@ public:
|
||||||
bool flush_txpool(const std::vector<std::string>& args);
|
bool flush_txpool(const std::vector<std::string>& args);
|
||||||
|
|
||||||
bool output_histogram(const std::vector<std::string>& args);
|
bool output_histogram(const std::vector<std::string>& args);
|
||||||
|
|
||||||
|
bool print_coinbase_tx_sum(const std::vector<std::string>& args);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace daemonize
|
} // namespace daemonize
|
||||||
|
|
|
@ -215,6 +215,11 @@ t_command_server::t_command_server(
|
||||||
, std::bind(&t_command_parser_executor::output_histogram, &m_parser, p::_1)
|
, std::bind(&t_command_parser_executor::output_histogram, &m_parser, p::_1)
|
||||||
, "Print output histogram (amount, instances)"
|
, "Print output histogram (amount, instances)"
|
||||||
);
|
);
|
||||||
|
m_command_lookup.set_handler(
|
||||||
|
"print_coinbase_tx_sum"
|
||||||
|
, std::bind(&t_command_parser_executor::print_coinbase_tx_sum, &m_parser, p::_1)
|
||||||
|
, "Print sum of coinbase transactions (start height, block count)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_server::process_command_str(const std::string& cmd)
|
bool t_command_server::process_command_str(const std::string& cmd)
|
||||||
|
|
|
@ -1270,5 +1270,40 @@ bool t_rpc_command_executor::output_histogram(uint64_t min_count, uint64_t max_c
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t height, uint64_t count)
|
||||||
|
{
|
||||||
|
cryptonote::COMMAND_RPC_GET_COINBASE_TX_SUM::request req;
|
||||||
|
cryptonote::COMMAND_RPC_GET_COINBASE_TX_SUM::response res;
|
||||||
|
epee::json_rpc::error error_resp;
|
||||||
|
|
||||||
|
req.height = height;
|
||||||
|
req.count = count;
|
||||||
|
|
||||||
|
std::string fail_message = "Unsuccessful";
|
||||||
|
|
||||||
|
if (m_is_rpc)
|
||||||
|
{
|
||||||
|
if (!m_rpc_client->json_rpc_request(req, res, "get_coinbase_tx_sum", fail_message.c_str()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!m_rpc_server->on_get_coinbase_tx_sum(req, res, error_resp))
|
||||||
|
{
|
||||||
|
tools::fail_msg_writer() << fail_message.c_str();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tools::msg_writer() << "Sum of coinbase transactions between block heights ["
|
||||||
|
<< height << ", " << (height + count) << ") is "
|
||||||
|
<< cryptonote::print_money(res.emission_amount + res.fee_amount) << " "
|
||||||
|
<< "consisting of " << cryptonote::print_money(res.emission_amount)
|
||||||
|
<< " in emissions, and " << cryptonote::print_money(res.fee_amount) << " in fees";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}// namespace daemonize
|
}// namespace daemonize
|
||||||
|
|
|
@ -133,6 +133,8 @@ public:
|
||||||
bool flush_txpool(const std::string &txid);
|
bool flush_txpool(const std::string &txid);
|
||||||
|
|
||||||
bool output_histogram(uint64_t min_count, uint64_t max_count);
|
bool output_histogram(uint64_t min_count, uint64_t max_count);
|
||||||
|
|
||||||
|
bool print_coinbase_tx_sum(uint64_t height, uint64_t count);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace daemonize
|
} // namespace daemonize
|
||||||
|
|
|
@ -1266,6 +1266,14 @@ namespace cryptonote
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool core_rpc_server::on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp)
|
||||||
|
{
|
||||||
|
std::pair<uint64_t, uint64_t> amounts = m_core.get_coinbase_tx_sum(req.height, req.count);
|
||||||
|
res.emission_amount = amounts.first;
|
||||||
|
res.fee_amount = amounts.second;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res)
|
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -115,6 +115,7 @@ namespace cryptonote
|
||||||
MAP_JON_RPC_WE_IF("flush_txpool", on_flush_txpool, COMMAND_RPC_FLUSH_TRANSACTION_POOL, !m_restricted)
|
MAP_JON_RPC_WE_IF("flush_txpool", on_flush_txpool, COMMAND_RPC_FLUSH_TRANSACTION_POOL, !m_restricted)
|
||||||
MAP_JON_RPC_WE("get_output_histogram", on_get_output_histogram, COMMAND_RPC_GET_OUTPUT_HISTOGRAM)
|
MAP_JON_RPC_WE("get_output_histogram", on_get_output_histogram, COMMAND_RPC_GET_OUTPUT_HISTOGRAM)
|
||||||
MAP_JON_RPC_WE("get_version", on_get_version, COMMAND_RPC_GET_VERSION)
|
MAP_JON_RPC_WE("get_version", on_get_version, COMMAND_RPC_GET_VERSION)
|
||||||
|
MAP_JON_RPC_WE("get_coinbase_tx_sum", on_get_coinbase_tx_sum, COMMAND_RPC_GET_COINBASE_TX_SUM)
|
||||||
END_JSON_RPC_MAP()
|
END_JSON_RPC_MAP()
|
||||||
END_URI_MAP2()
|
END_URI_MAP2()
|
||||||
|
|
||||||
|
@ -160,6 +161,7 @@ namespace cryptonote
|
||||||
bool on_flush_txpool(const COMMAND_RPC_FLUSH_TRANSACTION_POOL::request& req, COMMAND_RPC_FLUSH_TRANSACTION_POOL::response& res, epee::json_rpc::error& error_resp);
|
bool on_flush_txpool(const COMMAND_RPC_FLUSH_TRANSACTION_POOL::request& req, COMMAND_RPC_FLUSH_TRANSACTION_POOL::response& res, epee::json_rpc::error& error_resp);
|
||||||
bool on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp);
|
bool on_get_output_histogram(const COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request& req, COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response& res, epee::json_rpc::error& error_resp);
|
||||||
bool on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp);
|
bool on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp);
|
||||||
|
bool on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp);
|
||||||
//-----------------------
|
//-----------------------
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1226,5 +1226,31 @@ namespace cryptonote
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
struct COMMAND_RPC_GET_COINBASE_TX_SUM
|
||||||
|
{
|
||||||
|
struct request
|
||||||
|
{
|
||||||
|
uint64_t height;
|
||||||
|
uint64_t count;
|
||||||
|
|
||||||
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
|
KV_SERIALIZE(height);
|
||||||
|
KV_SERIALIZE(count);
|
||||||
|
END_KV_SERIALIZE_MAP()
|
||||||
|
};
|
||||||
|
|
||||||
|
struct response
|
||||||
|
{
|
||||||
|
std::string status;
|
||||||
|
uint64_t emission_amount;
|
||||||
|
uint64_t fee_amount;
|
||||||
|
|
||||||
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
|
KV_SERIALIZE(status)
|
||||||
|
KV_SERIALIZE(emission_amount)
|
||||||
|
KV_SERIALIZE(fee_amount)
|
||||||
|
END_KV_SERIALIZE_MAP()
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue