-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ledger account iterator for the unconfirmed ledger set.
- Loading branch information
Showing
18 changed files
with
156 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include <nano/secure/account_iterator_impl.hpp> | ||
#include <nano/secure/ledger_set_any.hpp> | ||
|
||
template class nano::account_iterator<nano::ledger_set_any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
#include <nano/lib/numbers.hpp> | ||
#include <nano/secure/account_info.hpp> | ||
|
||
#include <optional> | ||
#include <utility> | ||
|
||
namespace nano::store | ||
{ | ||
class transaction; | ||
} | ||
|
||
namespace nano | ||
{ | ||
// This class iterates account entries | ||
template <typename T> | ||
class account_iterator | ||
{ | ||
public: | ||
account_iterator (); | ||
account_iterator (store::transaction const & transaction, T const & view, std::optional<std::pair<nano::account, nano::account_info>> const & item); | ||
bool operator== (account_iterator const & other) const; | ||
account_iterator & operator++ (); | ||
std::pair<nano::account, nano::account_info> const & operator* () const; | ||
std::pair<nano::account, nano::account_info> const * operator->() const; | ||
|
||
private: | ||
store::transaction const * transaction; | ||
T const * view{ nullptr }; | ||
std::optional<std::pair<nano::account, nano::account_info>> item; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <nano/secure/account_info.hpp> | ||
#include <nano/secure/account_iterator.hpp> | ||
|
||
template <typename T> | ||
nano::account_iterator<T>::account_iterator () | ||
{ | ||
} | ||
|
||
template <typename T> | ||
nano::account_iterator<T>::account_iterator (store::transaction const & transaction, T const & view, std::optional<std::pair<nano::account, nano::account_info>> const & item) : | ||
transaction{ &transaction }, | ||
view{ &view }, | ||
item{ item } | ||
{ | ||
} | ||
|
||
template <typename T> | ||
bool nano::account_iterator<T>::operator== (account_iterator const & other) const | ||
{ | ||
debug_assert (view == nullptr || other.view == nullptr || view == other.view); | ||
return item == other.item; | ||
} | ||
|
||
template <typename T> | ||
auto nano::account_iterator<T>::operator++ () -> account_iterator<T> & | ||
{ | ||
auto next = item.value ().first.number () + 1; | ||
if (next != 0) | ||
{ | ||
*this = view->account_lower_bound (*transaction, next); | ||
} | ||
else | ||
{ | ||
*this = account_iterator<T>{}; | ||
} | ||
return *this; | ||
} | ||
|
||
template <typename T> | ||
std::pair<nano::account, nano::account_info> const & nano::account_iterator<T>::operator* () const | ||
{ | ||
return item.value (); | ||
} | ||
|
||
template <typename T> | ||
std::pair<nano::account, nano::account_info> const * nano::account_iterator<T>::operator->() const | ||
{ | ||
return &item.value (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.