Avoiding setting compression type for empty accounts
This commit is contained in:
parent
4f02f0a966
commit
5850536fc8
|
@ -1874,6 +1874,7 @@ dependencies = [
|
|||
"base64 0.21.7",
|
||||
"bs58",
|
||||
"itertools",
|
||||
"log",
|
||||
"lz4",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -220,11 +220,11 @@ impl AccountStorageInterface for InmemoryAccountStore {
|
|||
) -> Result<Option<AccountData>, AccountLoadingError> {
|
||||
match self.account_store.entry(account_pk) {
|
||||
dashmap::mapref::entry::Entry::Occupied(occ) => {
|
||||
let acc = occ.get();
|
||||
let acc = acc.get_account_data(commitment);
|
||||
if let Some(account) = &acc {
|
||||
if account.account.lamports > 0 {
|
||||
Ok(acc)
|
||||
let account = occ.get().get_account_data(commitment);
|
||||
drop(occ);
|
||||
if let Some(account_data) = &account {
|
||||
if account_data.account.lamports > 0 {
|
||||
Ok(account)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
@ -256,9 +256,10 @@ impl AccountStorageInterface for InmemoryAccountStore {
|
|||
match self.accounts_by_owner.entry(program_pubkey) {
|
||||
dashmap::mapref::entry::Entry::Occupied(occ) => {
|
||||
let mut return_vec = vec![];
|
||||
for program_account in occ.get().iter() {
|
||||
let account_data = self.get_account(*program_account, commitment).await;
|
||||
if let Ok(Some(account_data)) = account_data {
|
||||
let program_pubkeys = occ.get();
|
||||
for program_account in program_pubkeys.iter() {
|
||||
let account_data = self.get_account(*program_account, commitment).await?;
|
||||
if let Some(account_data) = account_data {
|
||||
// recheck program owner and filters
|
||||
if account_data.account.owner.eq(&program_pubkey) {
|
||||
match &account_filters {
|
||||
|
|
|
@ -15,4 +15,5 @@ serde = {workspace = true}
|
|||
serde_json = {workspace = true}
|
||||
bs58 = {workspace = true}
|
||||
base64 = {workspace = true}
|
||||
anyhow = {workspace = true}
|
||||
anyhow = {workspace = true}
|
||||
log = {workspace = true}
|
|
@ -45,7 +45,17 @@ impl Data {
|
|||
pub fn data(&self) -> Vec<u8> {
|
||||
match self {
|
||||
Data::Uncompressed(d) => d.clone(),
|
||||
Data::Lz4 { binary, .. } => lz4::block::decompress(binary, None).unwrap(),
|
||||
Data::Lz4 { binary, len } => match lz4::block::decompress(binary, None) {
|
||||
Ok(res) => res,
|
||||
Err(e) => {
|
||||
log::error!(
|
||||
"error {e:?} decompressing data of size {}, data_size_set: {}",
|
||||
binary.len(),
|
||||
len
|
||||
);
|
||||
panic!()
|
||||
}
|
||||
},
|
||||
Data::Zstd { binary, .. } => zstd::bulk::decompress(binary, MAX_ACCOUNT_SIZE).unwrap(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue