Skip to content

Commit

Permalink
Set minimum difficulty for RPC "work_generate" (#2006)
Browse files Browse the repository at this point in the history
* Set minimum difficulty for RPC "work_generate"

* Update CLI --debug_opencl for low difficulty
  • Loading branch information
SergiySW authored and Russel Waters committed May 22, 2019
1 parent 0789409 commit f309379
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nano/lib/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ std::string nano::error_rpc_messages::message (int ev) const
case nano::error_rpc::confirmation_not_found:
return "Active confirmation not found";
case nano::error_rpc::difficulty_limit:
return "Difficulty above config limit";
return "Difficulty above config limit or below publish threshold";
case nano::error_rpc::invalid_balance:
return "Invalid balance number";
case nano::error_rpc::invalid_destinations:
Expand Down
5 changes: 5 additions & 0 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ int main (int argc, char * const * argv)
std::cerr << "Invalid difficulty\n";
result = -1;
}
else if (difficulty < network_constants.publish_threshold)
{
std::cerr << "Difficulty below publish threshold\n";
result = -1;
}
}
if (!result)
{
Expand Down
2 changes: 1 addition & 1 deletion nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4345,7 +4345,7 @@ void nano::json_handler::work_generate ()
ec = nano::error_rpc::bad_difficulty_format;
}
}
if (!ec && difficulty > node_rpc_config.max_work_generate_difficulty)
if (!ec && (difficulty > node_rpc_config.max_work_generate_difficulty || difficulty < node.network_params.network.publish_threshold))
{
ec = nano::error_rpc::difficulty_limit;
}
Expand Down

0 comments on commit f309379

Please sign in to comment.