Skip to content

Commit

Permalink
chore: cargo fmt --all
Browse files Browse the repository at this point in the history
Co-authored-by: Claudia Bartoli Duncan <[email protected]>
  • Loading branch information
guidiaz and clbartoli committed May 26, 2021
1 parent bc2c0ea commit b45f17a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
4 changes: 2 additions & 2 deletions bridges/centralized-ethereum/src/actors/dr_database.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use actix::prelude::*;
use ethabi::Bytes;
use serde::{Deserialize, Serialize};
use std::{cmp, collections::HashMap, fmt};
use ethabi::Bytes;
use web3::{types::U256};
use web3::types::U256;
use witnet_data_structures::chain::Hash;
use witnet_node::storage_mngr;

Expand Down
43 changes: 14 additions & 29 deletions bridges/centralized-ethereum/src/actors/eth_poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::{
create_wrb_contract,
};
use actix::prelude::*;
use std::{convert::TryFrom, time::Duration};
use ethabi::Bytes;
use std::{convert::TryFrom, time::Duration};
use web3::{
contract::{self, Contract},
types::{H160, U256},
Expand Down Expand Up @@ -96,43 +96,28 @@ impl EthPoller {
.await;

if let Ok(dr_bytes) = dr_bytes {
let dr_result: Result<Bytes, web3::contract::Error> = wrb_contract
let dr_tx_hash: Result<U256, web3::contract::Error> = wrb_contract
.query(
"readResult",
"readDrTxHash",
(U256::from(i),),
eth_account,
contract::Options::default(),
None,
)
.await;

if let Ok(dr_result) = dr_result {
if let Ok(dr_tx_hash) = dr_tx_hash {
// Non-empty result: this data request is already "Finished"
if !dr_result.is_empty() {
let dr_tx_hash: Result<U256, web3::contract::Error> =
wrb_contract
.query(
"readDrHash",
(U256::from(i),),
eth_account,
contract::Options::default(),
None,
)
.await;

if let Ok(dr_tx_hash) = dr_tx_hash {
log::debug!("[{}] already finished", i);
dr_database_addr.do_send(SetDrInfoBridge(
U256::from(i),
DrInfoBridge {
dr_bytes,
dr_state: DrState::Finished,
dr_tx_hash: Some(Hash::SHA256(dr_tx_hash.into())),
},
));
} else {
break;
}
if dr_tx_hash != U256::from(0u8) {
log::debug!("[{}] already finished", i);
dr_database_addr.do_send(SetDrInfoBridge(
U256::from(i),
DrInfoBridge {
dr_bytes,
dr_state: DrState::Finished,
dr_tx_hash: Some(Hash::SHA256(dr_tx_hash.into())),
},
));
} else {
log::info!("[{}] new dr in wrb", i);
dr_database_addr.do_send(SetDrInfoBridge(
Expand Down

0 comments on commit b45f17a

Please sign in to comment.