Skip to content

Commit

Permalink
chore(c-bridge): attend pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed May 13, 2024
1 parent 78abe66 commit 1d2b5ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
42 changes: 23 additions & 19 deletions bridges/centralized-ethereum/src/actors/dr_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub struct DrReporterMsg {
pub struct Report {
/// Data Request's unique query id as known by the WitnetOracle contract
pub dr_id: DrId,
/// Timestamp at which reported result was actually generated
/// Timestamp at which the reported result was actually generated
pub dr_timestamp: u64,
/// Hash of the Data Request Transaction in the Witnet blockchain
pub dr_tx_hash: Hash,
Expand Down Expand Up @@ -327,23 +327,26 @@ impl Handler<DrReporterMsg> for DrReporter {
}

if let Ok(x) = eth.balance(eth_from, None).await {
if x < eth_from_balance {
log::warn!(
"EVM address {} loss = -{} ETH",
eth_from,
Unit::Wei(&(eth_from_balance - x).to_string())
.to_eth_str()
.unwrap_or_default()
);
} else if x > eth_from_balance {
log::debug!(
"EVM address {} revenue = +{} ETH",
eth_from,
Unit::Wei(&(x - eth_from_balance).to_string())
.to_eth_str()
.unwrap_or_default()
);
eth_from_balance_alert = false;
match x.cmp(&eth_from_balance) {
std::cmp::Ordering::Less => {
log::warn!(
"EVM address {} loss = -{} ETH",
eth_from,
Unit::Wei(&(eth_from_balance - x).to_string())
.to_eth_str()
.unwrap_or_default()
);
}
std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
log::debug!(
"EVM address {} revenue = +{} ETH",
eth_from,
Unit::Wei(&(x - eth_from_balance).to_string())
.to_eth_str()
.unwrap_or_default()
);
eth_from_balance_alert = false;
}
}
}

Expand Down Expand Up @@ -386,10 +389,11 @@ fn parse_batch_report_error_log(
match (&query_id.value, &reason.value) {
(Token::Uint(query_id), Token::String(reason)) => Some((*query_id, reason.to_string())),
_ => {
panic!(
log::error!(
"Invalid BatchReportError params: {:?}",
batch_report_error_log_params
);
None
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions bridges/centralized-ethereum/src/actors/dr_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ impl DrSender {
};
} else {
// TODO: alert if number of big enough utxos is less number of drs to broadcast
// let req = jsonrpc::Request::method("getBalance")
// .timeout(Duration::from_millis(5_000))
// .params(witnet_node_pkh.clone().unwrap())
// .expect("getUtxoInfo params failed serialization");
// let res = witnet_client.send(req).await;
// log::debug!("Balance of {:?}: {:?} nanoWIT", witnet_node_pkh.unwrap(), res)
}

// process latest drs added or set as New in the database
Expand Down

0 comments on commit 1d2b5ba

Please sign in to comment.