Skip to content

Commit

Permalink
Add functions to allow pending_key objects to be in containers.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Mar 14, 2024
1 parent da4e9eb commit d681591
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nano/secure/pending_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ nano::account const & nano::pending_key::key () const
{
return account;
}

bool nano::pending_key::operator< (nano::pending_key const & other_a) const
{
return account == other_a.account ? hash < other_a.hash : account < other_a.account;
}
13 changes: 13 additions & 0 deletions nano/secure/pending_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ class pending_key final
pending_key (nano::account const &, nano::block_hash const &);
bool deserialize (nano::stream &);
bool operator== (nano::pending_key const &) const;
bool operator< (nano::pending_key const &) const;
nano::account const & key () const;
nano::account account{};
nano::block_hash hash{ 0 };
};
} // namespace nano

namespace std
{
template <>
struct hash<::nano::pending_key>
{
size_t operator() (::nano::pending_key const & data_a) const
{
return hash<::nano::uint512_union>{}({ ::nano::uint256_union{ data_a.account.number () }, data_a.hash });
}
};
}

0 comments on commit d681591

Please sign in to comment.