Skip to content

Commit

Permalink
Merge pull request #586 from oasislabs/willscott/feature/testnet
Browse files Browse the repository at this point in the history
Some minor cleanup to ethereum backends
  • Loading branch information
willscott authored Jul 6, 2018
2 parents a82f497 + 8eeed57 commit 0336583
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ethereum/src/beacon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ create_component!(
}),
[Arg::with_name("beacon-address")
.long("beacon-address")
.env("BEACON_ADDRESS")
.env("ENV_RandomBeaconOasis")
.help("Ethereum address at which the random beacon has been deployed")
.takes_value(true)]
);
38 changes: 38 additions & 0 deletions ethereum/src/entity_registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Ekiden ethereum registry backend.
use std::error::Error as StdError;
use std::mem;
use std::result::Result as StdResult;
use std::sync::{Arc, Mutex};

use ekiden_beacon_base::RandomBeacon;
Expand All @@ -10,8 +11,10 @@ use ekiden_common::environment::Environment;
use ekiden_common::error::{Error, Result};
use ekiden_common::futures::sync::oneshot;
use ekiden_common::futures::{future, BoxFuture, BoxStream, Future, FutureExt, Stream};
use ekiden_common::identity::EntityIdentity;
use ekiden_common::node::Node;
use ekiden_common::signature::Signed;
use ekiden_di;
use ekiden_epochtime::interface::EpochTime;
use ekiden_epochtime::local::{LocalTimeSourceNotifier, SystemTimeSource};
use ekiden_registry_base::*;
Expand Down Expand Up @@ -401,3 +404,38 @@ where
cache.watch_node_list()
}
}

pub type EthereumEntityRegistryViaWebsocket =
EthereumEntityRegistryBackend<web3::transports::WebSocket>;
create_component!(
ethereum,
"entity-registry-backend",
EthereumEntityRegistryViaWebsocket,
EntityRegistryBackend,
(|container: &mut Container| -> StdResult<Box<Any>, ekiden_di::error::Error> {
let environment = container.inject()?;
let client = container.inject::<Web3<web3::transports::WebSocket>>()?;
let local_identity = container.inject::<EntityIdentity>()?;
let storage = container.inject::<StorageBackend>()?;
let beacon = container.inject::<RandomBeacon>()?;

let args = container.get_arguments().unwrap();
let contract_address = value_t_or_exit!(args, "entity-registry-address", H160);

let instance: Arc<EntityRegistryBackend> =
Arc::new(EthereumEntityRegistryBackend::new(
client,
Arc::new(local_identity.get_entity()),
contract_address,
storage,
beacon,
environment,
).map_err(|e| ekiden_di::error::Error::from(e.description()))?);
Ok(Box::new(instance))
}),
[Arg::with_name("entity-registry-address")
.long("entity-registry-address")
.env("ENV_EntityRegistryOasis")
.help("Ethereum address at which the entity registry has been deployed")
.takes_value(true)]
);
4 changes: 2 additions & 2 deletions ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ pub mod web3_di;

pub use beacon::{EthereumRandomBeacon, EthereumRandomBeaconViaWebsocket};
pub use contract_registry::EthereumContractRegistryBackend;
pub use entity_registry::EthereumEntityRegistryBackend;
pub use entity_registry::{EthereumEntityRegistryBackend, EthereumEntityRegistryViaWebsocket};
pub use mockepoch::{EthereumMockTime, EthereumMockTimeViaWebsocket};
pub use stake::EthereumStake;
pub use stake::{EthereumStake, EthereumStakeViaWebsocket};
2 changes: 1 addition & 1 deletion ethereum/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ create_component!(
}),
[Arg::with_name("stake-address")
.long("stake-address")
.env("STAKE_ADDRESS")
.env("ENV_Stake")
.help("Ethereum address at which the stake contract has been deployed")
.takes_value(true)]
);

0 comments on commit 0336583

Please sign in to comment.