Skip to content

Commit

Permalink
Attempt to fetch account from block hash in RPC work_generate (#2339)
Browse files Browse the repository at this point in the history
Also fixes distributed_work relaying the account by not storing as a const ref
  • Loading branch information
guilhermelawless authored Oct 14, 2019
1 parent d4f4a8e commit cf77b55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nano/node/distributed_work.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class distributed_work final : public std::enable_shared_from_this<nano::distrib
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;
Expand Down
9 changes: 9 additions & 0 deletions nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit cf77b55

Please sign in to comment.