aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-11-06 14:23:26 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-11-16 19:21:45 +0000
commit31d80027b5cc59b48205334a9e361c6a75099592 (patch)
treea0d963aa0411b9d0f7c2738d81b90d06b09e49d4 /src/rpc
parentblockchain: remove "0 is height" shortcut from get_output_distribution (diff)
downloadmonero-31d80027b5cc59b48205334a9e361c6a75099592.tar.xz
tests: add unit tests for get_output_distribution
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp2
-rw-r--r--src/rpc/daemon_handler.cpp2
-rw-r--r--src/rpc/rpc_handler.cpp4
-rw-r--r--src/rpc/rpc_handler.h2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index c2e71bef8..df9eee781 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -2125,7 +2125,7 @@ namespace cryptonote
const uint64_t req_to_height = req.to_height ? req.to_height : (m_core.get_current_blockchain_height() - 1);
for (uint64_t amount: req.amounts)
{
- auto data = rpc::RpcHandler::get_output_distribution(m_core, amount, req.from_height, req_to_height, req.cumulative);
+ auto data = rpc::RpcHandler::get_output_distribution([this](uint64_t amount, uint64_t from, uint64_t to, uint64_t &start_height, std::vector<uint64_t> &distribution, uint64_t &base) { return m_core.get_output_distribution(amount, from, to, start_height, distribution, base); }, amount, req.from_height, req_to_height, req.cumulative);
if (!data)
{
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
diff --git a/src/rpc/daemon_handler.cpp b/src/rpc/daemon_handler.cpp
index 8822bd378..64a5cc858 100644
--- a/src/rpc/daemon_handler.cpp
+++ b/src/rpc/daemon_handler.cpp
@@ -751,7 +751,7 @@ namespace rpc
const uint64_t req_to_height = req.to_height ? req.to_height : (m_core.get_current_blockchain_height() - 1);
for (std::uint64_t amount : req.amounts)
{
- auto data = get_output_distribution(m_core, amount, req.from_height, req_to_height, req.cumulative);
+ auto data = rpc::RpcHandler::get_output_distribution([this](uint64_t amount, uint64_t from, uint64_t to, uint64_t &start_height, std::vector<uint64_t> &distribution, uint64_t &base) { return m_core.get_output_distribution(amount, from, to, start_height, distribution, base); }, amount, req.from_height, req_to_height, req.cumulative);
if (!data)
{
res.distributions.clear();
diff --git a/src/rpc/rpc_handler.cpp b/src/rpc/rpc_handler.cpp
index d4beb1928..63664bf8b 100644
--- a/src/rpc/rpc_handler.cpp
+++ b/src/rpc/rpc_handler.cpp
@@ -26,7 +26,7 @@ namespace rpc
}
boost::optional<output_distribution_data>
- RpcHandler::get_output_distribution(core& src, std::uint64_t amount, std::uint64_t from_height, std::uint64_t to_height, bool cumulative)
+ RpcHandler::get_output_distribution(const std::function<bool(uint64_t, uint64_t, uint64_t, uint64_t&, std::vector<uint64_t>&, uint64_t&)> &f, uint64_t amount, uint64_t from_height, uint64_t to_height, bool cumulative)
{
static struct D
{
@@ -43,7 +43,7 @@ namespace rpc
std::vector<std::uint64_t> distribution;
std::uint64_t start_height, base;
- if (!src.get_output_distribution(amount, from_height, to_height, start_height, distribution, base))
+ if (!f(amount, from_height, to_height, start_height, distribution, base))
return boost::none;
if (to_height > 0 && to_height >= from_height)
diff --git a/src/rpc/rpc_handler.h b/src/rpc/rpc_handler.h
index 3cccef78a..e0d520408 100644
--- a/src/rpc/rpc_handler.h
+++ b/src/rpc/rpc_handler.h
@@ -56,7 +56,7 @@ class RpcHandler
virtual std::string handle(const std::string& request) = 0;
static boost::optional<output_distribution_data>
- get_output_distribution(core& src, std::uint64_t amount, std::uint64_t from_height, std::uint64_t to_height, bool cumulative);
+ get_output_distribution(const std::function<bool(uint64_t, uint64_t, uint64_t, uint64_t&, std::vector<uint64_t>&, uint64_t&)> &f, uint64_t amount, uint64_t from_height, uint64_t to_height, bool cumulative);
};