Slimmer implementation of credit-only accounts (#4592)
* Add credit-only debit/data check to verify_instruction * Store credits and pass to accounts_db * Add InstructionErrors and tests * Relax account locks for credit-only accounts * Collect credit-only account credits before passing to accounts_db to store properly * Convert System Transfer accounts to credit-only, and fixup test * Functionalize collect_accounts to unit test * Review comments * Rebase
This commit is contained in:
@@ -220,13 +220,16 @@ impl AppendVec {
|
||||
}
|
||||
|
||||
#[allow(clippy::mutex_atomic)]
|
||||
pub fn append_accounts(&self, accounts: &[(StorageMeta, &Account)]) -> Vec<usize> {
|
||||
pub fn append_accounts(
|
||||
&self,
|
||||
accounts: &[(StorageMeta, &Pubkey, &Account, u64)],
|
||||
) -> Vec<usize> {
|
||||
let mut offset = self.append_offset.lock().unwrap();
|
||||
let mut rv = vec![];
|
||||
for (storage_meta, account) in accounts {
|
||||
for (storage_meta, _, account, lamports) in accounts {
|
||||
let meta_ptr = storage_meta as *const StorageMeta;
|
||||
let balance = AccountBalance {
|
||||
lamports: account.lamports,
|
||||
lamports: *lamports,
|
||||
owner: account.owner,
|
||||
executable: account.executable,
|
||||
};
|
||||
@@ -248,7 +251,7 @@ impl AppendVec {
|
||||
}
|
||||
|
||||
pub fn append_account(&self, storage_meta: StorageMeta, account: &Account) -> Option<usize> {
|
||||
self.append_accounts(&[(storage_meta, account)])
|
||||
self.append_accounts(&[(storage_meta, &Pubkey::default(), account, account.lamports)])
|
||||
.first()
|
||||
.cloned()
|
||||
}
|
||||
|
Reference in New Issue
Block a user