Attempt to fetch account from block hash in RPC work_generate (#2339)

Also fixes distributed_work relaying the account by not storing as a const ref
This commit is contained in:
Guilherme Lawless 2019-10-14 10:35:40 +01:00 committed by GitHub
commit cf77b55695
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -56,7 +56,7 @@ public:
unsigned int backoff; // in seconds
nano::node & node;
nano::root root;
boost::optional<nano::account> const & account;
boost::optional<nano::account> const account;
std::mutex mutex;
std::map<boost::asio::ip::address, uint16_t> outstanding;
std::vector<std::weak_ptr<nano::work_peer_request>> connections;

View file

@ -4791,6 +4791,15 @@ void nano::json_handler::work_generate ()
}
else
{
if (!account_opt.is_initialized ())
{
// Fetch account from block if not given
auto transaction_l (node.store.tx_begin_read ());
if (node.store.block_exists (transaction_l, hash))
{
account = node.store.block_account (transaction_l, hash);
}
}
auto secondary_work_peers_l (request.get<bool> ("secondary_work_peers", false));
auto const & peers_l (secondary_work_peers_l ? node.config.secondary_work_peers : node.config.work_peers);
if (node.work_generation_enabled (peers_l))