-
Notifications
You must be signed in to change notification settings - Fork 292
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
Conversation
bbb40c1
to
15b8205
Compare
Codecov ReportAttention: Patch coverage is
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 |
@@ -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, |
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.
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.
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.
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?
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.
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 #