Skip to content

Commit

Permalink
Improve wallet_history consistency with other RPC (#1654)
Browse files Browse the repository at this point in the history
wallet_account --> block_account
And prevent history for change blocks
  • Loading branch information
SergiySW authored Jan 28, 2019
1 parent 6f6506c commit 598e8a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nano/core_test/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4221,7 +4221,7 @@ TEST (rpc, wallet_history)
auto & history_node (response.json.get_child ("history"));
for (auto i (history_node.begin ()), n (history_node.end ()); i != n; ++i)
{
history_l.push_back (std::make_tuple (i->second.get<std::string> ("type"), i->second.get<std::string> ("account"), i->second.get<std::string> ("amount"), i->second.get<std::string> ("hash"), i->second.get<std::string> ("wallet_account"), i->second.get<std::string> ("local_timestamp")));
history_l.push_back (std::make_tuple (i->second.get<std::string> ("type"), i->second.get<std::string> ("account"), i->second.get<std::string> ("amount"), i->second.get<std::string> ("hash"), i->second.get<std::string> ("block_account"), i->second.get<std::string> ("local_timestamp")));
}
ASSERT_EQ (4, history_l.size ());
ASSERT_EQ ("send", std::get<0> (history_l[0]));
Expand Down
11 changes: 7 additions & 4 deletions nano/node/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3519,12 +3519,15 @@ void nano::rpc_handler::wallet_history ()
if (block != nullptr && timestamp >= modified_since && timestamp != std::numeric_limits<uint64_t>::max ())
{
boost::property_tree::ptree entry;
entry.put ("wallet_account", account.to_account ());
entry.put ("hash", hash.to_string ());
history_visitor visitor (*this, false, block_transaction, entry, hash);
block->visit (visitor);
entry.put ("local_timestamp", std::to_string (timestamp));
entries.insert (std::make_pair (timestamp, entry));
if (!entry.empty ())
{
entry.put ("block_account", account.to_account ());
entry.put ("hash", hash.to_string ());
entry.put ("local_timestamp", std::to_string (timestamp));
entries.insert (std::make_pair (timestamp, entry));
}
hash = block->previous ();
}
else
Expand Down

0 comments on commit 598e8a3

Please sign in to comment.