-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More efficient database scan iteration
- Loading branch information
1 parent
5bf11b6
commit 3d6e181
Showing
5 changed files
with
153 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,61 @@ | ||
#pragma once | ||
|
||
#include <nano/lib/numbers.hpp> | ||
#include <nano/node/fwd.hpp> | ||
#include <nano/secure/pending_info.hpp> | ||
|
||
#include <deque> | ||
|
||
namespace nano | ||
namespace nano::bootstrap_ascending | ||
{ | ||
class ledger; | ||
} | ||
|
||
namespace nano::secure | ||
struct account_database_iterator | ||
{ | ||
class transaction; | ||
} | ||
explicit account_database_iterator (nano::ledger &); | ||
|
||
namespace nano::bootstrap_ascending | ||
{ | ||
class database_iterator | ||
std::deque<nano::account> next_batch (nano::store::transaction &, size_t batch_size); | ||
bool warmed_up () const; | ||
|
||
nano::ledger & ledger; | ||
nano::account next{ 0 }; | ||
size_t completed{ 0 }; | ||
}; | ||
|
||
struct pending_database_iterator | ||
{ | ||
public: | ||
enum class table_type | ||
{ | ||
account, | ||
pending | ||
}; | ||
explicit pending_database_iterator (nano::ledger &); | ||
|
||
explicit database_iterator (nano::ledger & ledger, table_type); | ||
nano::account operator* () const; | ||
void next (secure::transaction & tx); | ||
std::deque<nano::account> next_batch (nano::store::transaction &, size_t batch_size); | ||
bool warmed_up () const; | ||
|
||
private: | ||
nano::ledger & ledger; | ||
nano::account current{ 0 }; | ||
const table_type table; | ||
nano::pending_key next{ 0, 0 }; | ||
size_t completed{ 0 }; | ||
}; | ||
|
||
class buffered_iterator | ||
class database_scan | ||
{ | ||
public: | ||
explicit buffered_iterator (nano::ledger & ledger); | ||
explicit database_scan (nano::ledger &); | ||
|
||
nano::account operator* () const; | ||
nano::account next (std::function<bool (nano::account const &)> const & filter); | ||
|
||
// Indicates if a full ledger iteration has taken place e.g. warmed up | ||
bool warmup () const; | ||
bool warmed_up () const; | ||
|
||
std::unique_ptr<nano::container_info_component> collect_container_info (std::string const & name) const; | ||
|
||
private: // Dependencies | ||
nano::ledger & ledger; | ||
|
||
private: | ||
void fill (); | ||
|
||
private: | ||
nano::ledger & ledger; | ||
std::deque<nano::account> buffer; | ||
bool warmup_m{ true }; | ||
account_database_iterator accounts_iterator; | ||
pending_database_iterator pending_iterator; | ||
|
||
database_iterator accounts_iterator; | ||
database_iterator pending_iterator; | ||
std::deque<nano::account> queue; | ||
|
||
static std::size_t constexpr size = 1024; | ||
static size_t constexpr batch_size = 128; | ||
}; | ||
} // nano::bootstrap_ascending | ||
} |
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