Skip to content

Commit

Permalink
retry to get config account
Browse files Browse the repository at this point in the history
  • Loading branch information
miralandlabs committed Aug 10, 2024
1 parent 09eaeb0 commit 7d3cd0a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/dynamic_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Miner {
}
};

// // Send request in one steop
// // Send request in one step
// let response: Value = client
// .post(rpc_url)
// .json(&body)
Expand Down
24 changes: 20 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,26 @@ pub async fn _get_treasury(client: &RpcClient) -> Treasury {
}

pub async fn get_config(client: &RpcClient) -> Config {
let data = client
.get_account_data(&CONFIG_ADDRESS)
.await
.expect("Failed to get config account");
// MI: vanilla
// let data = client
// .get_account_data(&CONFIG_ADDRESS)
// .await
// .expect("Failed to get config account");

let data: Vec<u8>;
loop {
match client.get_account_data(&CONFIG_ADDRESS).await {
Ok(d) => {
data = d;
break;
}
Err(e) => {
println!("get config account error: {:?}", e);
println!("retry to get config account...");
}
}
}

*Config::try_from_bytes(&data).expect("Failed to parse config account")
}

Expand Down

0 comments on commit 7d3cd0a

Please sign in to comment.