Removing redundent data length field
This commit is contained in:
parent
2eb9cd242a
commit
d12a6b538d
|
@ -2345,7 +2345,6 @@ mod tests {
|
|||
owner: Pubkey::default(),
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length: 0,
|
||||
}),
|
||||
updated_slot: 2,
|
||||
write_version: 3,
|
||||
|
@ -2358,7 +2357,6 @@ mod tests {
|
|||
owner: Pubkey::default(),
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length: 0,
|
||||
}),
|
||||
updated_slot: 2,
|
||||
write_version: 4,
|
||||
|
|
|
@ -63,8 +63,6 @@ pub struct Account {
|
|||
pub executable: bool,
|
||||
/// the epoch at which this account will next owe rent
|
||||
pub rent_epoch: u64,
|
||||
//uncompressed data length
|
||||
pub data_length: u64,
|
||||
}
|
||||
|
||||
impl Account {
|
||||
|
@ -72,7 +70,6 @@ impl Account {
|
|||
account: SolanaAccount,
|
||||
compression_method: CompressionMethod,
|
||||
) -> Self {
|
||||
let data_length = account.data.len() as u64;
|
||||
let data = match compression_method {
|
||||
CompressionMethod::None => Data::Uncompressed(account.data),
|
||||
CompressionMethod::Lz4(level) => {
|
||||
|
@ -97,7 +94,6 @@ impl Account {
|
|||
owner: account.owner,
|
||||
executable: account.executable,
|
||||
rent_epoch: account.rent_epoch,
|
||||
data_length,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,16 +67,16 @@ pub fn get_token_program_account_type(
|
|||
|
||||
if account_data.account.owner == spl_token_2022::ID {
|
||||
let data = account_data.account.data.data();
|
||||
let (type_account, additional_data) = if account_data.account.data_length == 82 {
|
||||
let (type_account, additional_data) = if account_data.account.data.len() == 82 {
|
||||
//mint
|
||||
(0, false)
|
||||
} else if account_data.account.data_length == 165 {
|
||||
} else if account_data.account.data.len() == 165 {
|
||||
// token account
|
||||
(1, false)
|
||||
} else if account_data.account.data_length == 355 {
|
||||
} else if account_data.account.data.len() == 355 {
|
||||
// multisig
|
||||
(2, false)
|
||||
} else if account_data.account.data_length > 165 {
|
||||
} else if account_data.account.data.len() > 165 {
|
||||
// extended token account
|
||||
if data[165] == 1 {
|
||||
//mint
|
||||
|
@ -166,7 +166,7 @@ pub fn get_token_program_account_type(
|
|||
_ => unreachable!(),
|
||||
}
|
||||
} else if account_data.account.owner == spl_token::ID {
|
||||
if account_data.account.data_length == 82 {
|
||||
if account_data.account.data.len() == 82 {
|
||||
// mint
|
||||
let mint = spl_token::state::Mint::unpack(&account_data.account.data.data())?;
|
||||
Ok(TokenProgramAccountType::Mint(MintAccount {
|
||||
|
@ -180,7 +180,7 @@ pub fn get_token_program_account_type(
|
|||
freeze_authority: mint.freeze_authority.into(),
|
||||
additional_data: None,
|
||||
}))
|
||||
} else if account_data.account.data_length == 165 {
|
||||
} else if account_data.account.data.len() == 165 {
|
||||
//token account
|
||||
let token_account =
|
||||
spl_token::state::Account::unpack(&account_data.account.data.data())?;
|
||||
|
@ -215,7 +215,7 @@ pub fn get_token_program_account_type(
|
|||
}))
|
||||
} else {
|
||||
// multisig
|
||||
assert_eq!(account_data.account.data_length, 355);
|
||||
assert_eq!(account_data.account.data.len(), 355);
|
||||
let multi_sig = spl_token::state::Multisig::unpack(&account_data.account.data.data())?;
|
||||
Ok(TokenProgramAccountType::MultiSig(
|
||||
MultiSig {
|
||||
|
@ -326,7 +326,6 @@ pub fn token_account_to_solana_account(
|
|||
},
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length,
|
||||
});
|
||||
Some(AccountData {
|
||||
pubkey: token_account.pubkey,
|
||||
|
@ -377,7 +376,6 @@ pub fn token_mint_to_solana_account(
|
|||
}
|
||||
};
|
||||
|
||||
let data_length = data.len() as u64;
|
||||
let account = Arc::new(Account {
|
||||
lamports: mint_account.lamports,
|
||||
data: lite_account_manager_common::account_data::Data::Uncompressed(data),
|
||||
|
@ -387,7 +385,6 @@ pub fn token_mint_to_solana_account(
|
|||
},
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length,
|
||||
});
|
||||
AccountData {
|
||||
pubkey: mint_account.pubkey,
|
||||
|
@ -431,7 +428,6 @@ pub fn token_multisig_to_solana_account(
|
|||
data
|
||||
}
|
||||
};
|
||||
let data_length = data.len() as u64;
|
||||
let account = Arc::new(Account {
|
||||
lamports: multsig.lamports,
|
||||
data: lite_account_manager_common::account_data::Data::Uncompressed(data),
|
||||
|
@ -441,7 +437,6 @@ pub fn token_multisig_to_solana_account(
|
|||
},
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length,
|
||||
});
|
||||
AccountData {
|
||||
pubkey,
|
||||
|
|
|
@ -387,7 +387,6 @@ pub async fn test_saving_and_loading_token_account() {
|
|||
owner: Pubkey::default(),
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length: 0,
|
||||
}),
|
||||
updated_slot: 6,
|
||||
write_version: 6,
|
||||
|
|
|
@ -123,7 +123,6 @@ pub fn create_token_account_data(
|
|||
owner: spl_token::id(),
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length: 165,
|
||||
}),
|
||||
updated_slot: slot,
|
||||
write_version,
|
||||
|
@ -188,7 +187,6 @@ pub fn create_mint_account_data(
|
|||
owner: spl_token::id(),
|
||||
executable: false,
|
||||
rent_epoch: u64::MAX,
|
||||
data_length: 82,
|
||||
}),
|
||||
updated_slot: slot,
|
||||
write_version,
|
||||
|
|
Loading…
Reference in New Issue