Skip to content

Commit

Permalink
handle fee estimate rquest in 2 steps
Browse files Browse the repository at this point in the history
  • Loading branch information
miralandlabs committed Aug 10, 2024
1 parent a9f7cff commit 09eaeb0
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/dynamic_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,34 @@ impl Miner {
}
};

// Send request
let response: Value = client
// // Send request in one steop
// let response: Value = client
// .post(rpc_url)
// .json(&body)
// .send()
// .await
// .unwrap()
// .json()
// .await
// .unwrap();

// MI, Send request in two steps
// split json from send
// 1) handle response
let Ok(resp) = client
.post(rpc_url)
.json(&body)
.send()
.await
.unwrap()
.json()
.await
.unwrap();
.await else {
eprintln!("didn't get dynamic fee estimate, use default instead.");
return Ok(5000);
};

// 2) handle json
let Ok(response) = resp.json::<Value>().await else {
eprintln!("didn't get json data from fee estimate response, use default instead.");
return Ok(5000);
};

// Parse response
let calculated_fee = match strategy {
Expand Down

0 comments on commit 09eaeb0

Please sign in to comment.