From 1f9de770d523c2863d2ac0b0da20fd26bdfe52db Mon Sep 17 00:00:00 2001 From: Guilherme Lawless Date: Thu, 30 Apr 2020 19:40:29 +0100 Subject: [PATCH] Result difficulty in RPC block_create --- nano/node/json_handler.cpp | 1 + nano/rpc_test/rpc.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index 9d715044a1..3120afda19 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -1370,6 +1370,7 @@ void nano::json_handler::block_create () auto block_response_put_l = [rpc_l, this](nano::block const & block_a) { boost::property_tree::ptree response_l; response_l.put ("hash", block_a.hash ().to_string ()); + response_l.put ("difficulty", nano::to_string_hex (block_a.difficulty ())); bool json_block_l = request.get ("json_block", false); if (json_block_l) { diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index ae8e64c819..6fd6cf0d34 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -5826,6 +5826,8 @@ TEST (rpc, block_create) ASSERT_EQ (200, response.status); std::string send_hash (response.json.get ("hash")); ASSERT_EQ (send.hash ().to_string (), send_hash); + std::string send_difficulty (response.json.get ("difficulty")); + ASSERT_EQ (nano::to_string_hex (send.difficulty ()), send_difficulty); auto send_text (response.json.get ("block")); boost::property_tree::ptree block_l; std::stringstream block_stream (send_text);