Skip to content
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

account_default_if_zero_lamport always returns a value #822

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

jeffwashington
Copy link

Problem

moving to not mmapping append vec files. Soon, lifetimes of borrowed account data will be limited to a callback.

Summary of Changes

Rework StorableAccounts.account_default_if_zero_lamport() to always return a value.
This simplifies the api and allows a callback to work better when the data's lifetime is limited. Life time changes are coming soon.

Fixes #

@jeffwashington jeffwashington force-pushed the 4a81 branch 3 times, most recently from bbb40c1 to 15b8205 Compare April 15, 2024 21:16
@codecov-commenter
Copy link

codecov-commenter commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 81.8%. Comparing base (7f16e84) to head (ddb3641).

Additional details and impacted files
@@            Coverage Diff            @@
##           master     #822     +/-   ##
=========================================
- Coverage    81.8%    81.8%   -0.1%     
=========================================
  Files         851      851             
  Lines      231616   231595     -21     
=========================================
- Hits       189603   189554     -49     
- Misses      42013    42041     +28     

@jeffwashington jeffwashington marked this pull request as ready for review April 16, 2024 00:17
@@ -90,10 +96,14 @@ pub trait StorableAccounts<'a>: Sync {
fn account_default_if_zero_lamport<Ret>(
&self,
index: usize,
mut callback: impl FnMut(Option<AccountForStorage<'a>>) -> Ret,
mut callback: impl FnMut(AccountForStorage<'a>) -> Ret,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this change goes in, I think it'll be valuable to consolidate account() and account_default_if_zero_lamport() into a single method. Supporting both of these is likely unnecessary, and removing one will make code easier to reason about IMO.

I'd love to get to a point where we don't need to special case how we handle lamports == 0 here, and instead can guarantee callers always handle lamports == 0 properly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. I would have to look into the details of why we want this or don't. Maybe we always want to set to default?

accounts-db/src/storable_accounts.rs Show resolved Hide resolved
Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jeffwashington jeffwashington merged commit c75fe56 into anza-xyz:master Apr 16, 2024
38 checks passed
michaelschem pushed a commit to michaelschem/agave that referenced this pull request Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants