Set minimum difficulty for RPC "work_generate" (#2006)

* Set minimum difficulty for RPC "work_generate"

* Update CLI --debug_opencl for low difficulty
This commit is contained in:
Sergey Kroshnin 2019-05-22 15:46:39 +03:00 committed by GitHub
commit f7765c148d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -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:

View file

@ -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)
{

View file

@ -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;
}