Skip to content

Commit 5db1043

Browse files
committed
chore(c-bridge): attend pr review comments
1 parent 3d6efdc commit 5db1043

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

bridges/centralized-ethereum/src/actors/dr_reporter.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub struct DrReporterMsg {
101101
pub struct Report {
102102
/// Data Request's unique query id as known by the WitnetOracle contract
103103
pub dr_id: DrId,
104-
/// Timestamp at which reported result was actually generated
104+
/// Timestamp at which the reported result was actually generated
105105
pub dr_timestamp: u64,
106106
/// Hash of the Data Request Transaction in the Witnet blockchain
107107
pub dr_tx_hash: Hash,
@@ -327,23 +327,26 @@ impl Handler<DrReporterMsg> for DrReporter {
327327
}
328328

329329
if let Ok(x) = eth.balance(eth_from, None).await {
330-
if x < eth_from_balance {
331-
log::warn!(
332-
"EVM address {} loss = -{} ETH",
333-
eth_from,
334-
Unit::Wei(&(eth_from_balance - x).to_string())
335-
.to_eth_str()
336-
.unwrap_or_default()
337-
);
338-
} else if x > eth_from_balance {
339-
log::debug!(
340-
"EVM address {} revenue = +{} ETH",
341-
eth_from,
342-
Unit::Wei(&(x - eth_from_balance).to_string())
343-
.to_eth_str()
344-
.unwrap_or_default()
345-
);
346-
eth_from_balance_alert = false;
330+
match x.cmp(&eth_from_balance) {
331+
std::cmp::Ordering::Less => {
332+
log::warn!(
333+
"EVM address {} loss = -{} ETH",
334+
eth_from,
335+
Unit::Wei(&(eth_from_balance - x).to_string())
336+
.to_eth_str()
337+
.unwrap_or_default()
338+
);
339+
}
340+
std::cmp::Ordering::Equal | std::cmp::Ordering::Greater => {
341+
log::debug!(
342+
"EVM address {} revenue = +{} ETH",
343+
eth_from,
344+
Unit::Wei(&(x - eth_from_balance).to_string())
345+
.to_eth_str()
346+
.unwrap_or_default()
347+
);
348+
eth_from_balance_alert = false;
349+
}
347350
}
348351
}
349352

@@ -386,10 +389,11 @@ fn parse_batch_report_error_log(
386389
match (&query_id.value, &reason.value) {
387390
(Token::Uint(query_id), Token::String(reason)) => Some((*query_id, reason.to_string())),
388391
_ => {
389-
panic!(
392+
log::error!(
390393
"Invalid BatchReportError params: {:?}",
391394
batch_report_error_log_params
392395
);
396+
None
393397
}
394398
}
395399
}

bridges/centralized-ethereum/src/actors/dr_sender.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ impl DrSender {
112112
};
113113
} else {
114114
// TODO: alert if number of big enough utxos is less number of drs to broadcast
115-
// let req = jsonrpc::Request::method("getBalance")
116-
// .timeout(Duration::from_millis(5_000))
117-
// .params(witnet_node_pkh.clone().unwrap())
118-
// .expect("getUtxoInfo params failed serialization");
119-
// let res = witnet_client.send(req).await;
120-
// log::debug!("Balance of {:?}: {:?} nanoWIT", witnet_node_pkh.unwrap(), res)
121115
}
122116

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

0 commit comments

Comments
 (0)