Skip to content

Commit

Permalink
Fix RPC "active_difficulty" returning empty string as "difficulty_tre…
Browse files Browse the repository at this point in the history
…nd" (#3323) (#3343)

* Fix RPC "active_difficulty" returning empty string as "difficulty_trend" (#3323)

* Change active_difficulty test unit accordingly
  • Loading branch information
shryder authored Jun 16, 2021
1 parent 77dae8a commit baa7f43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,14 @@ void nano::json_handler::active_difficulty ()
response_l.put ("multiplier", 1.0);
if (include_trend)
{
boost::property_tree::ptree trend_entry_l;
response_l.add_child ("difficulty_trend", trend_entry_l);
boost::property_tree::ptree difficulty_trend_l;

// To keep this RPC backwards-compatible
boost::property_tree::ptree entry;
entry.put ("", "1.000000000000000");
difficulty_trend_l.push_back (std::make_pair ("", entry));

response_l.add_child ("difficulty_trend", difficulty_trend_l);
}
response_errors ();
}
Expand Down
2 changes: 1 addition & 1 deletion nano/rpc_test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7159,7 +7159,7 @@ TEST (rpc, active_difficulty)
auto trend_opt (response.json.get_child_optional ("difficulty_trend"));
ASSERT_TRUE (trend_opt.is_initialized ());
auto & trend (trend_opt.get ());
ASSERT_EQ (0, trend.size ());
ASSERT_EQ (1, trend.size ());
}
}

Expand Down

0 comments on commit baa7f43

Please sign in to comment.