-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ledger confirmed_set/any_set classes to separate confirmed-only and confirmed/unconfirmed operations on the ledger #4486
Conversation
Changed base file class name to ledger_view_base and renamed the user-facing class to ledger_view. |
Rebased on top of #4484 |
e8059be
to
0655adc
Compare
55ac5d9
to
3d681c6
Compare
I reworked this from the previous ledger_view design for several reasons:
|
0143f27
to
ebe67dd
Compare
82d480c
to
69c7913
Compare
f7b83ad
to
c192843
Compare
return block_balance > previous_balance.value () ? block_balance.number () - previous_balance.value ().number () : previous_balance.value ().number () - block_balance.number (); | ||
} | ||
|
||
// Balance for account containing hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems wrong, it can be removed since the name of the function is now obvious.
|
||
std::optional<nano::amount> nano::ledger_set_any::account_balance (secure::transaction const & transaction, nano::account const & account_a) const | ||
{ | ||
auto block = block_get (transaction, ledger.any.account_head (transaction, account_a)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ledger.any
seems redundant
|
||
public: // Operations on pending entries | ||
std::optional<nano::pending_info> pending_get (secure::transaction const & transaction, nano::pending_key const & key) const; | ||
bool receivable_any (secure::transaction const & transaction, nano::account const & account) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deleted
…exists in the confirmed ledger set.
…et height(account) overload.
The motivation for this PR is in preparation for bounded backlog changes. Currently, both confirmed and unconfirmed transactions are together on disk and the ACID properties of the ledger are encapsulated with a database transaction.
With the bounded backlog, blocks will be stored in memory so there will need to be memory synchronization in addition to database synchronization. Rather than filling the ledger class with unconfirmed/confirmed variants for each operation.
The ledger is divided in to several sets and subsets:
ledger::confirmed - The set of confirmed transactions
ledger::any - The superset of confirmed and unconfirmed transactions
When unconfirmed blocks are held in memory the set ledger::unconfirmed will be added which holds only unconfirmed transactions.
In the future the confirming_set can be moved on to ledger which is the subset of unconfirmed blocks that are queued to be moved in to the confirmed set.