cli: Stop topping up buffer balance (#20181)

This commit is contained in:
Justin Starry
2021-09-29 12:27:18 -04:00
committed by GitHub
parent c02ef395ed
commit 53a810dbad

View File

@ -2037,24 +2037,24 @@ fn complete_partial_program_init(
if account.owner != *loader_id { if account.owner != *loader_id {
instructions.push(system_instruction::assign(elf_pubkey, loader_id)); instructions.push(system_instruction::assign(elf_pubkey, loader_id));
} }
} if account.lamports < minimum_balance {
if account.lamports < minimum_balance { let balance = minimum_balance - account.lamports;
let balance = minimum_balance - account.lamports; instructions.push(system_instruction::transfer(
instructions.push(system_instruction::transfer( payer_pubkey,
payer_pubkey, elf_pubkey,
elf_pubkey, balance,
balance, ));
)); balance_needed = balance;
balance_needed = balance; } else if account.lamports > minimum_balance
} else if account.lamports > minimum_balance && system_program::check_id(&account.owner)
&& system_program::check_id(&account.owner) && !allow_excessive_balance
&& !allow_excessive_balance {
{ return Err(format!(
return Err(format!( "Buffer account has a balance: {:?}; it may already be in use",
"Buffer account has a balance: {:?}; it may already be in use", Sol(account.lamports)
Sol(account.lamports) )
) .into());
.into()); }
} }
Ok((instructions, balance_needed)) Ok((instructions, balance_needed))
} }