Skip to content

Commit

Permalink
fix: get attestations correctly for closable info
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyhodl committed Nov 19, 2024
1 parent f778410 commit 2ba6b52
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions dlc-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,24 +584,40 @@ where
})
.enumerate()
.collect();

if matured.len() >= contract_info.threshold {
let mut attestations = Vec::new();
for (i, announcement) in matured {
let oracle = self.oracles.get(&announcement.oracle_public_key)?;
let attestation =
let oracle = match self.oracles.get(&announcement.oracle_public_key) {
Some(o) => o,
None => {
log::warn!(
"No oracle found with pubkey. pubkey={}",
announcement.oracle_public_key
);
continue;
}
};
let Ok(attestation) =
maybe_await!(oracle.get_attestation(&announcement.oracle_event.event_id))
.ok()?;
attestation
.validate(&self.secp, announcement)
.map_err(|_| {
log::error!(
"Oracle attestation is not valid. pubkey={} event_id={}",
announcement.oracle_public_key,
announcement.oracle_event.event_id
)
})
.ok()?;
else {
log::warn!(
"Failed to get attestation. oracle={} event_id={}",
announcement.oracle_public_key,
announcement.oracle_event.event_id
);
continue;
};

if let Err(error) = attestation.validate(&self.secp, announcement) {
log::warn!(
"Oracle attestation is invalid. error={} pubkey={} event_id={}",
error,
announcement.oracle_public_key,
announcement.oracle_event.event_id
);
continue;
}

attestations.push((i, attestation));
}
if attestations.len() >= contract_info.threshold {
Expand Down

0 comments on commit 2ba6b52

Please sign in to comment.