Skip to content

Commit

Permalink
apply_compute_budget correctly for sweep command
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Mar 14, 2024
1 parent f0ee0c1 commit acd931a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async fn retry_get_historical_price(
token.get_historical_price(rpc_client, block_date).await
}

#[derive(Default, Debug)]
#[derive(Default, Debug, Clone, Copy)]
struct ComputeBudget {
compute_unit_price_micro_lamports: Option<u64>,
compute_unit_limit: Option<u32>,
Expand Down Expand Up @@ -3176,6 +3176,8 @@ async fn process_account_sweep<T: Signers>(

let (signature, maybe_transaction) = match existing_signature {
None => {
apply_compute_budget(rpc_client, &mut instructions, compute_budget);

let mut message = Message::new(&instructions, Some(&from_authority_address));
message.recent_blockhash = recent_blockhash;

Expand All @@ -3193,8 +3195,6 @@ async fn process_account_sweep<T: Signers>(
println!("TODO: account for priority fee in lot split...");
}

apply_compute_budget(rpc_client, &mut instructions, compute_budget);

let mut transaction = Transaction::new_unsigned(message);
let simulation_result = rpc_client.simulate_transaction(&transaction)?.value;
if simulation_result.err.is_some() {
Expand Down

0 comments on commit acd931a

Please sign in to comment.