Skip to content

Commit

Permalink
Populate relayer sigset response with actual fee data
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Oct 11, 2023
1 parent 45bed5a commit 31ca610
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/bitcoin/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,17 @@ impl Relayer {
let sigset_route = warp::path("sigset")
.and_then(move || async {
let sigset = app_client(app_client_addr)
.query(|app| {
let sigset: RawSignatorySet =
app.bitcoin.checkpoints.active_sigset()?.into();
.query(|app: crate::app::InnerApp| {
let building = app.bitcoin.checkpoints.building()?;
let est_miner_fee = building.fee_rate
* app.bitcoin.checkpoints.active_sigset()?.est_witness_vsize();
let deposits_enabled = building.deposits_enabled;
let sigset = RawSignatorySet::new(
app.bitcoin.checkpoints.active_sigset()?,
0.015,
est_miner_fee as f64 / 100_000_000.0,
deposits_enabled,
);
Ok(sigset)
})
.await
Expand Down Expand Up @@ -761,8 +769,13 @@ pub struct RawSignatorySet {
pub deposits_enabled: bool,
}

impl From<SignatorySet> for RawSignatorySet {
fn from(sigset: SignatorySet) -> Self {
impl RawSignatorySet {
pub fn new(
sigset: SignatorySet,
bridge_fee_rate: f64,
miner_fee_rate: f64,
deposits_enabled: bool,
) -> Self {
let signatories = sigset
.iter()
.map(|s| RawSignatory::from(s.clone()))
Expand All @@ -771,10 +784,9 @@ impl From<SignatorySet> for RawSignatorySet {
RawSignatorySet {
signatories,
index: sigset.index(),
// TODO
bridge_fee_rate: 0.015,
miner_fee_rate: 0.0001,
deposits_enabled: true,
bridge_fee_rate,
miner_fee_rate,
deposits_enabled,
}
}
}
Expand Down

0 comments on commit 31ca610

Please sign in to comment.