Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,6 @@ pub trait ReadableAccount: Sized {
fn owner(&self) -> &Pubkey;
fn executable(&self) -> bool;
fn rent_epoch(&self) -> Epoch;
fn to_account_shared_data(&self) -> AccountSharedData {
AccountSharedData::create(
self.lamports(),
self.data().to_vec(),
*self.owner(),
self.executable(),
self.rent_epoch(),
)
}
}

impl ReadableAccount for Account {
Expand Down Expand Up @@ -343,10 +334,6 @@ impl ReadableAccount for AccountSharedData {
fn rent_epoch(&self) -> Epoch {
self.rent_epoch
}
fn to_account_shared_data(&self) -> AccountSharedData {
// avoid data copy here
self.clone()
}
}

impl ReadableAccount for Ref<'_, AccountSharedData> {
Expand All @@ -365,16 +352,6 @@ impl ReadableAccount for Ref<'_, AccountSharedData> {
fn rent_epoch(&self) -> Epoch {
self.rent_epoch
}
fn to_account_shared_data(&self) -> AccountSharedData {
AccountSharedData {
lamports: self.lamports(),
// avoid data copy here
data: Arc::clone(&self.data),
owner: *self.owner(),
executable: self.executable(),
rent_epoch: self.rent_epoch(),
}
}
}

impl ReadableAccount for Ref<'_, Account> {
Expand Down Expand Up @@ -917,17 +894,6 @@ pub mod tests {
account2.serialize_data(&"hello world").unwrap();
}

#[test]
fn test_to_account_shared_data() {
let key = Pubkey::new_unique();
let (account1, account2) = make_two_accounts(&key);
assert!(accounts_equal(&account1, &account2));
let account3 = account1.to_account_shared_data();
let account4 = account2.to_account_shared_data();
assert!(accounts_equal(&account1, &account3));
assert!(accounts_equal(&account1, &account4));
}

#[test]
fn test_account_shared_data() {
let key = Pubkey::new_unique();
Expand Down