Always and fully normalize stored 0-lamport accts. (#8657) (#8661)

(cherry picked from commit f146c92e88)

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
Michael Vines
2020-03-05 09:49:26 -07:00
committed by GitHub
parent f32c152bce
commit 4d9aee4794
2 changed files with 81 additions and 5 deletions

View File

@@ -1033,22 +1033,25 @@ impl AccountsDB {
accounts: &[(&Pubkey, &Account)],
hashes: &[Hash],
) -> Vec<AccountInfo> {
let default_account = Account::default();
let with_meta: Vec<(StoredMeta, &Account)> = accounts
.iter()
.map(|(pubkey, account)| {
let write_version = self.write_version.fetch_add(1, Ordering::Relaxed) as u64;
let data_len = if account.lamports == 0 {
0
let account = if account.lamports == 0 {
&default_account
} else {
account.data.len() as u64
*account
};
let data_len = account.data.len() as u64;
let meta = StoredMeta {
write_version,
pubkey: **pubkey,
data_len,
};
(meta, *account)
(meta, account)
})
.collect();
let mut infos: Vec<AccountInfo> = Vec::with_capacity(with_meta.len());