fix compile warnings (#10993)

* fix warnings

* fix: failing build, use `spec` as dev-dependency
This commit is contained in:
Niklas Adolfsson 2019-08-27 17:29:33 +02:00 committed by Andronik Ordian
parent 505e284932
commit dab2a6bd4b
69 changed files with 203 additions and 199 deletions

View File

@ -284,7 +284,7 @@ impl<T> KeyDirectory for DiskDirectory<T> where T: KeyFileManager {
fn path(&self) -> Option<&PathBuf> { Some(&self.path) } fn path(&self) -> Option<&PathBuf> { Some(&self.path) }
fn as_vault_provider(&self) -> Option<&VaultKeyDirectoryProvider> { fn as_vault_provider(&self) -> Option<&dyn VaultKeyDirectoryProvider> {
Some(self) Some(self)
} }
@ -294,12 +294,12 @@ impl<T> KeyDirectory for DiskDirectory<T> where T: KeyFileManager {
} }
impl<T> VaultKeyDirectoryProvider for DiskDirectory<T> where T: KeyFileManager { impl<T> VaultKeyDirectoryProvider for DiskDirectory<T> where T: KeyFileManager {
fn create(&self, name: &str, key: VaultKey) -> Result<Box<VaultKeyDirectory>, Error> { fn create(&self, name: &str, key: VaultKey) -> Result<Box<dyn VaultKeyDirectory>, Error> {
let vault_dir = VaultDiskDirectory::create(&self.path, name, key)?; let vault_dir = VaultDiskDirectory::create(&self.path, name, key)?;
Ok(Box::new(vault_dir)) Ok(Box::new(vault_dir))
} }
fn open(&self, name: &str, key: VaultKey) -> Result<Box<VaultKeyDirectory>, Error> { fn open(&self, name: &str, key: VaultKey) -> Result<Box<dyn VaultKeyDirectory>, Error> {
let vault_dir = VaultDiskDirectory::at(&self.path, name, key)?; let vault_dir = VaultDiskDirectory::at(&self.path, name, key)?;
Ok(Box::new(vault_dir)) Ok(Box::new(vault_dir))
} }

View File

@ -57,7 +57,7 @@ pub trait KeyDirectory: Send + Sync {
/// Get directory filesystem path, if available /// Get directory filesystem path, if available
fn path(&self) -> Option<&PathBuf> { None } fn path(&self) -> Option<&PathBuf> { None }
/// Return vault provider, if available /// Return vault provider, if available
fn as_vault_provider(&self) -> Option<&VaultKeyDirectoryProvider> { None } fn as_vault_provider(&self) -> Option<&dyn VaultKeyDirectoryProvider> { None }
/// Unique representation of directory account collection /// Unique representation of directory account collection
fn unique_repr(&self) -> Result<u64, Error>; fn unique_repr(&self) -> Result<u64, Error>;
} }
@ -65,9 +65,9 @@ pub trait KeyDirectory: Send + Sync {
/// Vaults provider /// Vaults provider
pub trait VaultKeyDirectoryProvider { pub trait VaultKeyDirectoryProvider {
/// Create new vault with given key /// Create new vault with given key
fn create(&self, name: &str, key: VaultKey) -> Result<Box<VaultKeyDirectory>, Error>; fn create(&self, name: &str, key: VaultKey) -> Result<Box<dyn VaultKeyDirectory>, Error>;
/// Open existing vault with given key /// Open existing vault with given key
fn open(&self, name: &str, key: VaultKey) -> Result<Box<VaultKeyDirectory>, Error>; fn open(&self, name: &str, key: VaultKey) -> Result<Box<dyn VaultKeyDirectory>, Error>;
/// List all vaults /// List all vaults
fn list_vaults(&self) -> Result<Vec<String>, Error>; fn list_vaults(&self) -> Result<Vec<String>, Error>;
/// Get vault meta /// Get vault meta
@ -77,7 +77,7 @@ pub trait VaultKeyDirectoryProvider {
/// Vault directory /// Vault directory
pub trait VaultKeyDirectory: KeyDirectory { pub trait VaultKeyDirectory: KeyDirectory {
/// Cast to `KeyDirectory` /// Cast to `KeyDirectory`
fn as_key_directory(&self) -> &KeyDirectory; fn as_key_directory(&self) -> &dyn KeyDirectory;
/// Vault name /// Vault name
fn name(&self) -> &str; fn name(&self) -> &str;
/// Get vault key /// Get vault key

View File

@ -119,7 +119,7 @@ impl VaultDiskDirectory {
} }
impl VaultKeyDirectory for VaultDiskDirectory { impl VaultKeyDirectory for VaultDiskDirectory {
fn as_key_directory(&self) -> &KeyDirectory { fn as_key_directory(&self) -> &dyn KeyDirectory {
self self
} }

View File

@ -36,12 +36,12 @@ pub struct EthStore {
impl EthStore { impl EthStore {
/// Open a new accounts store with given key directory backend. /// Open a new accounts store with given key directory backend.
pub fn open(directory: Box<KeyDirectory>) -> Result<Self, Error> { pub fn open(directory: Box<dyn KeyDirectory>) -> Result<Self, Error> {
Self::open_with_iterations(directory, KEY_ITERATIONS as u32) Self::open_with_iterations(directory, KEY_ITERATIONS as u32)
} }
/// Open a new account store with given key directory backend and custom number of iterations. /// Open a new account store with given key directory backend and custom number of iterations.
pub fn open_with_iterations(directory: Box<KeyDirectory>, iterations: u32) -> Result<Self, Error> { pub fn open_with_iterations(directory: Box<dyn KeyDirectory>, iterations: u32) -> Result<Self, Error> {
Ok(EthStore { Ok(EthStore {
store: EthMultiStore::open_with_iterations(directory, iterations)?, store: EthMultiStore::open_with_iterations(directory, iterations)?,
}) })
@ -184,7 +184,7 @@ impl SecretStore for EthStore {
Ok(account.check_password(password)) Ok(account.check_password(password))
} }
fn copy_account(&self, new_store: &SimpleSecretStore, new_vault: SecretVaultRef, account: &StoreAccountRef, password: &Password, new_password: &Password) -> Result<(), Error> { fn copy_account(&self, new_store: &dyn SimpleSecretStore, new_vault: SecretVaultRef, account: &StoreAccountRef, password: &Password, new_password: &Password) -> Result<(), Error> {
let account = self.get(account)?; let account = self.get(account)?;
let secret = account.crypto.secret(password)?; let secret = account.crypto.secret(password)?;
new_store.insert_account(new_vault, secret, new_password)?; new_store.insert_account(new_vault, secret, new_password)?;
@ -256,11 +256,11 @@ impl SecretStore for EthStore {
/// Similar to `EthStore` but may store many accounts (with different passwords) for the same `Address` /// Similar to `EthStore` but may store many accounts (with different passwords) for the same `Address`
pub struct EthMultiStore { pub struct EthMultiStore {
dir: Box<KeyDirectory>, dir: Box<dyn KeyDirectory>,
iterations: u32, iterations: u32,
// order lock: cache, then vaults // order lock: cache, then vaults
cache: RwLock<BTreeMap<StoreAccountRef, Vec<SafeAccount>>>, cache: RwLock<BTreeMap<StoreAccountRef, Vec<SafeAccount>>>,
vaults: Mutex<HashMap<String, Box<VaultKeyDirectory>>>, vaults: Mutex<HashMap<String, Box<dyn VaultKeyDirectory>>>,
timestamp: Mutex<Timestamp>, timestamp: Mutex<Timestamp>,
} }
@ -272,12 +272,12 @@ struct Timestamp {
impl EthMultiStore { impl EthMultiStore {
/// Open new multi-accounts store with given key directory backend. /// Open new multi-accounts store with given key directory backend.
pub fn open(directory: Box<KeyDirectory>) -> Result<Self, Error> { pub fn open(directory: Box<dyn KeyDirectory>) -> Result<Self, Error> {
Self::open_with_iterations(directory, KEY_ITERATIONS as u32) Self::open_with_iterations(directory, KEY_ITERATIONS as u32)
} }
/// Open new multi-accounts store with given key directory backend and custom number of iterations for new keys. /// Open new multi-accounts store with given key directory backend and custom number of iterations for new keys.
pub fn open_with_iterations(directory: Box<KeyDirectory>, iterations: u32) -> Result<Self, Error> { pub fn open_with_iterations(directory: Box<dyn KeyDirectory>, iterations: u32) -> Result<Self, Error> {
let store = EthMultiStore { let store = EthMultiStore {
dir: directory, dir: directory,
vaults: Mutex::new(HashMap::new()), vaults: Mutex::new(HashMap::new()),

View File

@ -24,7 +24,7 @@ use dir;
use Error; use Error;
/// Import an account from a file. /// Import an account from a file.
pub fn import_account(path: &Path, dst: &KeyDirectory) -> Result<Address, Error> { pub fn import_account(path: &Path, dst: &dyn KeyDirectory) -> Result<Address, Error> {
let key_manager = DiskKeyFileManager::default(); let key_manager = DiskKeyFileManager::default();
let existing_accounts = dst.load()?.into_iter().map(|a| a.address).collect::<HashSet<_>>(); let existing_accounts = dst.load()?.into_iter().map(|a| a.address).collect::<HashSet<_>>();
let filename = path.file_name().and_then(|n| n.to_str()).map(|f| f.to_owned()); let filename = path.file_name().and_then(|n| n.to_str()).map(|f| f.to_owned());
@ -40,7 +40,7 @@ pub fn import_account(path: &Path, dst: &KeyDirectory) -> Result<Address, Error>
} }
/// Import all accounts from one directory to the other. /// Import all accounts from one directory to the other.
pub fn import_accounts(src: &KeyDirectory, dst: &KeyDirectory) -> Result<Vec<Address>, Error> { pub fn import_accounts(src: &dyn KeyDirectory, dst: &dyn KeyDirectory) -> Result<Vec<Address>, Error> {
let accounts = src.load()?; let accounts = src.load()?;
let existing_accounts = dst.load()?.into_iter() let existing_accounts = dst.load()?.into_iter()
.map(|a| a.address) .map(|a| a.address)
@ -64,7 +64,7 @@ pub fn read_geth_accounts(testnet: bool) -> Vec<Address> {
} }
/// Import specific `desired` accounts from the Geth keystore into `dst`. /// Import specific `desired` accounts from the Geth keystore into `dst`.
pub fn import_geth_accounts(dst: &KeyDirectory, desired: HashSet<Address>, testnet: bool) -> Result<Vec<Address>, Error> { pub fn import_geth_accounts(dst: &dyn KeyDirectory, desired: HashSet<Address>, testnet: bool) -> Result<Vec<Address>, Error> {
let src = RootDiskDirectory::at(dir::geth(testnet)); let src = RootDiskDirectory::at(dir::geth(testnet));
let accounts = src.load()?; let accounts = src.load()?;
let existing_accounts = dst.load()?.into_iter().map(|a| a.address).collect::<HashSet<_>>(); let existing_accounts = dst.load()?.into_iter().map(|a| a.address).collect::<HashSet<_>>();

View File

@ -118,7 +118,7 @@ pub trait SecretStore: SimpleSecretStore {
/// Imports existing JSON wallet /// Imports existing JSON wallet
fn import_wallet(&self, vault: SecretVaultRef, json: &[u8], password: &Password, gen_id: bool) -> Result<StoreAccountRef, Error>; fn import_wallet(&self, vault: SecretVaultRef, json: &[u8], password: &Password, gen_id: bool) -> Result<StoreAccountRef, Error>;
/// Copies account between stores and vaults. /// Copies account between stores and vaults.
fn copy_account(&self, new_store: &SimpleSecretStore, new_vault: SecretVaultRef, account: &StoreAccountRef, password: &Password, new_password: &Password) -> Result<(), Error>; fn copy_account(&self, new_store: &dyn SimpleSecretStore, new_vault: SecretVaultRef, account: &StoreAccountRef, password: &Password, new_password: &Password) -> Result<(), Error>;
/// Checks if password matches given account. /// Checks if password matches given account.
fn test_password(&self, account: &StoreAccountRef, password: &Password) -> Result<bool, Error>; fn test_password(&self, account: &StoreAccountRef, password: &Password) -> Result<bool, Error>;

View File

@ -64,7 +64,7 @@ pub struct AccountProvider {
/// Address book. /// Address book.
address_book: RwLock<AddressBook>, address_book: RwLock<AddressBook>,
/// Accounts on disk /// Accounts on disk
sstore: Box<SecretStore>, sstore: Box<dyn SecretStore>,
/// Accounts unlocked with rolling tokens /// Accounts unlocked with rolling tokens
transient_sstore: EthMultiStore, transient_sstore: EthMultiStore,
/// When unlocking account permanently we additionally keep a raw secret in memory /// When unlocking account permanently we additionally keep a raw secret in memory
@ -80,7 +80,7 @@ fn transient_sstore() -> EthMultiStore {
impl AccountProvider { impl AccountProvider {
/// Creates new account provider. /// Creates new account provider.
pub fn new(sstore: Box<SecretStore>, settings: AccountProviderSettings) -> Self { pub fn new(sstore: Box<dyn SecretStore>, settings: AccountProviderSettings) -> Self {
if let Ok(accounts) = sstore.accounts() { if let Ok(accounts) = sstore.accounts() {
for account in accounts.into_iter().filter(|a| settings.blacklisted_accounts.contains(&a.address)) { for account in accounts.into_iter().filter(|a| settings.blacklisted_accounts.contains(&a.address)) {
warn!("Local Account {} has a blacklisted (known to be weak) address and will be ignored", warn!("Local Account {} has a blacklisted (known to be weak) address and will be ignored",

View File

@ -36,7 +36,7 @@ extern crate log;
extern crate matches; extern crate matches;
/// Boxed future response. /// Boxed future response.
pub type BoxFuture<T, E> = Box<futures::Future<Item=T, Error=E> + Send>; pub type BoxFuture<T, E> = Box<dyn futures::Future<Item=T, Error=E> + Send>;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {

View File

@ -138,7 +138,7 @@ pub enum Error {
} }
impl error::Error for Error { impl error::Error for Error {
fn source(&self) -> Option<&(error::Error + 'static)> { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self { match self {
Error::Io(e) => Some(e), Error::Io(e) => Some(e),
Error::Decoder(e) => Some(e), Error::Decoder(e) => Some(e),

View File

@ -63,7 +63,6 @@ extern crate transaction_pool as txpool;
extern crate url; extern crate url;
#[macro_use] #[macro_use]
extern crate log as ethlog; extern crate log as ethlog;
#[macro_use]
extern crate ethabi_derive; extern crate ethabi_derive;
#[macro_use] #[macro_use]
extern crate ethabi_contract; extern crate ethabi_contract;
@ -205,17 +204,17 @@ impl Signer for KeyPairSigner {
/// Manager of private transactions /// Manager of private transactions
pub struct Provider { pub struct Provider {
encryptor: Box<Encryptor>, encryptor: Box<dyn Encryptor>,
validator_accounts: HashSet<Address>, validator_accounts: HashSet<Address>,
signer_account: Option<Address>, signer_account: Option<Address>,
notify: RwLock<Vec<Weak<ChainNotify>>>, notify: RwLock<Vec<Weak<dyn ChainNotify>>>,
transactions_for_signing: RwLock<SigningStore>, transactions_for_signing: RwLock<SigningStore>,
transactions_for_verification: VerificationStore, transactions_for_verification: VerificationStore,
client: Arc<Client>, client: Arc<Client>,
miner: Arc<Miner>, miner: Arc<Miner>,
accounts: Arc<Signer>, accounts: Arc<dyn Signer>,
channel: IoChannel<ClientIoMessage>, channel: IoChannel<ClientIoMessage>,
keys_provider: Arc<KeyProvider>, keys_provider: Arc<dyn KeyProvider>,
logging: Option<Logging>, logging: Option<Logging>,
use_offchain_storage: bool, use_offchain_storage: bool,
state_storage: PrivateStateStorage, state_storage: PrivateStateStorage,
@ -234,12 +233,12 @@ impl Provider {
pub fn new( pub fn new(
client: Arc<Client>, client: Arc<Client>,
miner: Arc<Miner>, miner: Arc<Miner>,
accounts: Arc<Signer>, accounts: Arc<dyn Signer>,
encryptor: Box<Encryptor>, encryptor: Box<dyn Encryptor>,
config: ProviderConfig, config: ProviderConfig,
channel: IoChannel<ClientIoMessage>, channel: IoChannel<ClientIoMessage>,
keys_provider: Arc<KeyProvider>, keys_provider: Arc<dyn KeyProvider>,
db: Arc<KeyValueDB>, db: Arc<dyn KeyValueDB>,
) -> Self { ) -> Self {
keys_provider.update_acl_contract(); keys_provider.update_acl_contract();
Provider { Provider {
@ -268,11 +267,11 @@ impl Provider {
// TODO [ToDr] Don't use `ChainNotify` here! // TODO [ToDr] Don't use `ChainNotify` here!
// Better to create a separate notification type for this. // Better to create a separate notification type for this.
/// Adds an actor to be notified on certain events /// Adds an actor to be notified on certain events
pub fn add_notify(&self, target: Arc<ChainNotify>) { pub fn add_notify(&self, target: Arc<dyn ChainNotify>) {
self.notify.write().push(Arc::downgrade(&target)); self.notify.write().push(Arc::downgrade(&target));
} }
fn notify<F>(&self, f: F) where F: Fn(&ChainNotify) { fn notify<F>(&self, f: F) where F: Fn(&dyn ChainNotify) {
for np in self.notify.read().iter() { for np in self.notify.read().iter() {
if let Some(n) = np.upgrade() { if let Some(n) = np.upgrade() {
f(&*n); f(&*n);

View File

@ -186,13 +186,13 @@ impl LogsSerializer for FileLogsSerializer {
/// Private transactions logging /// Private transactions logging
pub struct Logging { pub struct Logging {
logs: RwLock<HashMap<H256, TransactionLog>>, logs: RwLock<HashMap<H256, TransactionLog>>,
logs_serializer: Arc<LogsSerializer>, logs_serializer: Arc<dyn LogsSerializer>,
mono_time: MonoTime, mono_time: MonoTime,
} }
impl Logging { impl Logging {
/// Creates the logging object /// Creates the logging object
pub fn new(logs_serializer: Arc<LogsSerializer>) -> Self { pub fn new(logs_serializer: Arc<dyn LogsSerializer>) -> Self {
let mut logging = Logging { let mut logging = Logging {
logs: RwLock::new(HashMap::new()), logs: RwLock::new(HashMap::new()),
logs_serializer, logs_serializer,

View File

@ -25,12 +25,12 @@ use error::Error;
/// Wrapper around local db with private state for sync purposes /// Wrapper around local db with private state for sync purposes
pub struct PrivateStateDB { pub struct PrivateStateDB {
db: Arc<KeyValueDB>, db: Arc<dyn KeyValueDB>,
} }
impl PrivateStateDB { impl PrivateStateDB {
/// Constructs the object /// Constructs the object
pub fn new(db: Arc<KeyValueDB>) -> Self { pub fn new(db: Arc<dyn KeyValueDB>) -> Self {
PrivateStateDB { PrivateStateDB {
db, db,
} }

View File

@ -57,7 +57,7 @@ pub struct PrivateStateStorage {
impl PrivateStateStorage { impl PrivateStateStorage {
/// Constructs the object /// Constructs the object
pub fn new(db: Arc<KeyValueDB>) -> Self { pub fn new(db: Arc<dyn KeyValueDB>) -> Self {
PrivateStateStorage { PrivateStateStorage {
private_state_db: Arc::new(PrivateStateDB::new(db)), private_state_db: Arc::new(PrivateStateDB::new(db)),
requests: RwLock::new(Vec::new()), requests: RwLock::new(Vec::new()),

View File

@ -94,7 +94,7 @@ pub struct ClientService {
client: Arc<Client>, client: Arc<Client>,
snapshot: Arc<SnapshotService>, snapshot: Arc<SnapshotService>,
private_tx: Arc<PrivateTxService>, private_tx: Arc<PrivateTxService>,
database: Arc<BlockChainDB>, database: Arc<dyn BlockChainDB>,
} }
impl ClientService { impl ClientService {
@ -102,13 +102,13 @@ impl ClientService {
pub fn start( pub fn start(
config: ClientConfig, config: ClientConfig,
spec: &Spec, spec: &Spec,
blockchain_db: Arc<BlockChainDB>, blockchain_db: Arc<dyn BlockChainDB>,
snapshot_path: &Path, snapshot_path: &Path,
restoration_db_handler: Box<BlockChainDBHandler>, restoration_db_handler: Box<dyn BlockChainDBHandler>,
_ipc_path: &Path, _ipc_path: &Path,
miner: Arc<Miner>, miner: Arc<Miner>,
signer: Arc<Signer>, signer: Arc<dyn Signer>,
encryptor: Box<ethcore_private_tx::Encryptor>, encryptor: Box<dyn ethcore_private_tx::Encryptor>,
private_tx_conf: ethcore_private_tx::ProviderConfig, private_tx_conf: ethcore_private_tx::ProviderConfig,
private_encryptor_conf: ethcore_private_tx::EncryptorConfig, private_encryptor_conf: ethcore_private_tx::EncryptorConfig,
) -> Result<ClientService, EthcoreError> ) -> Result<ClientService, EthcoreError>
@ -173,7 +173,7 @@ impl ClientService {
} }
/// Get general IO interface /// Get general IO interface
pub fn register_io_handler(&self, handler: Arc<IoHandler<ClientIoMessage> + Send>) -> Result<(), IoError> { pub fn register_io_handler(&self, handler: Arc<dyn IoHandler<ClientIoMessage> + Send>) -> Result<(), IoError> {
self.io_service.register_handler(handler) self.io_service.register_handler(handler)
} }
@ -198,12 +198,12 @@ impl ClientService {
} }
/// Set the actor to be notified on certain chain events /// Set the actor to be notified on certain chain events
pub fn add_notify(&self, notify: Arc<ChainNotify>) { pub fn add_notify(&self, notify: Arc<dyn ChainNotify>) {
self.client.add_notify(notify); self.client.add_notify(notify);
} }
/// Get a handle to the database. /// Get a handle to the database.
pub fn db(&self) -> Arc<BlockChainDB> { self.database.clone() } pub fn db(&self) -> Arc<dyn BlockChainDB> { self.database.clone() }
/// Shutdown the Client Service /// Shutdown the Client Service
pub fn shutdown(&self) { pub fn shutdown(&self) {

View File

@ -743,7 +743,7 @@ impl SyncHandler {
Ok(()) Ok(())
} }
fn on_private_state_data(sync: &mut ChainSync, io: &mut SyncIo, peer_id: PeerId, r: &Rlp) -> Result<(), DownloaderImportError> { fn on_private_state_data(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId, r: &Rlp) -> Result<(), DownloaderImportError> {
if !sync.peers.get(&peer_id).map_or(false, |p| p.can_sync()) { if !sync.peers.get(&peer_id).map_or(false, |p| p.can_sync()) {
trace!(target: "sync", "{} Ignoring packet from unconfirmed/unknown peer", peer_id); trace!(target: "sync", "{} Ignoring packet from unconfirmed/unknown peer", peer_id);
return Ok(()); return Ok(());

View File

@ -1382,7 +1382,7 @@ impl ChainSync {
} }
/// Request private state from peers /// Request private state from peers
pub fn request_private_state(&mut self, io: &mut SyncIo, hash: &H256) { pub fn request_private_state(&mut self, io: &mut dyn SyncIo, hash: &H256) {
let private_state_peers = self.get_private_state_peers(); let private_state_peers = self.get_private_state_peers();
if private_state_peers.is_empty() { if private_state_peers.is_empty() {
error!(target: "privatetx", "Cannot request private state, no peers with private tx enabled available"); error!(target: "privatetx", "Cannot request private state, no peers with private tx enabled available");

View File

@ -100,7 +100,7 @@ impl SyncRequester {
SyncRequester::send_request(sync, io, peer_id, PeerAsking::SnapshotManifest, GetSnapshotManifestPacket, rlp.out()); SyncRequester::send_request(sync, io, peer_id, PeerAsking::SnapshotManifest, GetSnapshotManifestPacket, rlp.out());
} }
pub fn request_private_state(sync: &mut ChainSync, io: &mut SyncIo, peer_id: PeerId, hash: &H256) { pub fn request_private_state(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId, hash: &H256) {
trace!(target: "privatetx", "{} <- GetPrivateStatePacket", peer_id); trace!(target: "privatetx", "{} <- GetPrivateStatePacket", peer_id);
let mut rlp = RlpStream::new_list(1); let mut rlp = RlpStream::new_list(1);
rlp.append(hash); rlp.append(hash);

View File

@ -356,7 +356,7 @@ impl SyncSupplier {
} }
/// Respond to GetPrivateStatePacket /// Respond to GetPrivateStatePacket
fn return_private_state(io: &SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult { fn return_private_state(io: &dyn SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let hash: H256 = r.val_at(0)?; let hash: H256 = r.val_at(0)?;
trace!(target: "privatetx", "{} -> GetPrivateStatePacket {:?}", peer_id, hash); trace!(target: "privatetx", "{} -> GetPrivateStatePacket {:?}", peer_id, hash);
io.private_state().map_or(Ok(None), |db| { io.private_state().map_or(Ok(None), |db| {

View File

@ -107,11 +107,11 @@ pub trait NodeInfo: Send + Sync {
/// Create a new local data store, given a database, a column to write to, and a node. /// Create a new local data store, given a database, a column to write to, and a node.
/// Attempts to read data out of the store, and move it into the node. /// Attempts to read data out of the store, and move it into the node.
pub fn create<T: NodeInfo>(db: Arc<KeyValueDB>, col: Option<u32>, node: T) -> LocalDataStore<T> { pub fn create<T: NodeInfo>(db: Arc<dyn KeyValueDB>, col: Option<u32>, node: T) -> LocalDataStore<T> {
LocalDataStore { LocalDataStore {
db: db, db,
col: col, col,
node: node, node,
} }
} }
@ -120,7 +120,7 @@ pub fn create<T: NodeInfo>(db: Arc<KeyValueDB>, col: Option<u32>, node: T) -> Lo
/// In specific, this will be used to store things like unpropagated local transactions /// In specific, this will be used to store things like unpropagated local transactions
/// and the node security level. /// and the node security level.
pub struct LocalDataStore<T: NodeInfo> { pub struct LocalDataStore<T: NodeInfo> {
db: Arc<KeyValueDB>, db: Arc<dyn KeyValueDB>,
col: Option<u32>, col: Option<u32>,
node: T, node: T,
} }

View File

@ -70,7 +70,7 @@ pub struct Stratum {
impl Stratum { impl Stratum {
pub fn start( pub fn start(
addr: &SocketAddr, addr: &SocketAddr,
dispatcher: Arc<JobDispatcher>, dispatcher: Arc<dyn JobDispatcher>,
secret: Option<H256>, secret: Option<H256>,
) -> Result<Arc<Stratum>, Error> { ) -> Result<Arc<Stratum>, Error> {
@ -128,7 +128,7 @@ struct StratumImpl {
/// List of workers supposed to receive job update /// List of workers supposed to receive job update
job_que: RwLock<HashSet<SocketAddr>>, job_que: RwLock<HashSet<SocketAddr>>,
/// Payload manager /// Payload manager
dispatcher: Arc<JobDispatcher>, dispatcher: Arc<dyn JobDispatcher>,
/// Authorized workers (socket - worker_id) /// Authorized workers (socket - worker_id)
workers: Arc<RwLock<HashMap<SocketAddr, String>>>, workers: Arc<RwLock<HashMap<SocketAddr, String>>>,
/// Secret if any /// Secret if any

View File

@ -199,14 +199,14 @@ mod accounts {
} }
} }
pub fn private_tx_signer(accounts: Arc<AccountProvider>, passwords: &[Password]) -> Result<Arc<::ethcore_private_tx::Signer>, String> { pub fn private_tx_signer(accounts: Arc<AccountProvider>, passwords: &[Password]) -> Result<Arc<dyn (ethcore_private_tx::Signer)>, String> {
Ok(Arc::new(self::private_tx::AccountSigner { Ok(Arc::new(self::private_tx::AccountSigner {
accounts, accounts,
passwords: passwords.to_vec(), passwords: passwords.to_vec(),
})) }))
} }
pub fn accounts_list(account_provider: Arc<AccountProvider>) -> Arc<Fn() -> Vec<Address> + Send + Sync> { pub fn accounts_list(account_provider: Arc<AccountProvider>) -> Arc<dyn Fn() -> Vec<Address> + Send + Sync> {
Arc::new(move || account_provider.accounts().unwrap_or_default()) Arc::new(move || account_provider.accounts().unwrap_or_default())
} }

View File

@ -244,7 +244,7 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
let client = service.client(); let client = service.client();
let mut instream: Box<io::Read> = match cmd.file_path { let mut instream: Box<dyn io::Read> = match cmd.file_path {
Some(f) => Box::new(fs::File::open(&f).map_err(|_| format!("Cannot open given file: {}", f))?), Some(f) => Box::new(fs::File::open(&f).map_err(|_| format!("Cannot open given file: {}", f))?),
None => Box::new(io::stdin()), None => Box::new(io::stdin()),
}; };
@ -412,7 +412,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
let client = service.client(); let client = service.client();
let mut instream: Box<io::Read> = match cmd.file_path { let mut instream: Box<dyn io::Read> = match cmd.file_path {
Some(f) => Box::new(fs::File::open(&f).map_err(|_| format!("Cannot open given file: {}", f))?), Some(f) => Box::new(fs::File::open(&f).map_err(|_| format!("Cannot open given file: {}", f))?),
None => Box::new(io::stdin()), None => Box::new(io::stdin()),
}; };
@ -621,7 +621,7 @@ fn execute_export(cmd: ExportBlockchain) -> Result<(), String> {
let client = service.client(); let client = service.client();
let mut out: Box<io::Write> = match cmd.file_path { let mut out: Box<dyn io::Write> = match cmd.file_path {
Some(f) => Box::new(fs::File::create(&f).map_err(|_| format!("Cannot write to file given: {}", f))?), Some(f) => Box::new(fs::File::create(&f).map_err(|_| format!("Cannot write to file given: {}", f))?),
None => Box::new(io::stdout()), None => Box::new(io::stdout()),
}; };
@ -665,7 +665,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
let client = service.client(); let client = service.client();
let mut out: Box<io::Write> = match cmd.file_path { let mut out: Box<dyn io::Write> = match cmd.file_path {
Some(f) => Box::new(fs::File::create(&f).map_err(|_| format!("Cannot write to file given: {}", f))?), Some(f) => Box::new(fs::File::create(&f).map_err(|_| format!("Cannot write to file given: {}", f))?),
None => Box::new(io::stdout()), None => Box::new(io::stdout()),
}; };

View File

@ -37,13 +37,13 @@ mod helpers;
pub use self::migration::migrate; pub use self::migration::migrate;
struct AppDB { struct AppDB {
key_value: Arc<KeyValueDB>, key_value: Arc<dyn KeyValueDB>,
blooms: blooms_db::Database, blooms: blooms_db::Database,
trace_blooms: blooms_db::Database, trace_blooms: blooms_db::Database,
} }
impl BlockChainDB for AppDB { impl BlockChainDB for AppDB {
fn key_value(&self) -> &Arc<KeyValueDB> { fn key_value(&self) -> &Arc<dyn KeyValueDB> {
&self.key_value &self.key_value
} }
@ -58,7 +58,7 @@ impl BlockChainDB for AppDB {
/// Open a secret store DB using the given secret store data path. The DB path is one level beneath the data path. /// Open a secret store DB using the given secret store data path. The DB path is one level beneath the data path.
#[cfg(feature = "secretstore")] #[cfg(feature = "secretstore")]
pub fn open_secretstore_db(data_path: &str) -> Result<Arc<KeyValueDB>, String> { pub fn open_secretstore_db(data_path: &str) -> Result<Arc<dyn KeyValueDB>, String> {
use std::path::PathBuf; use std::path::PathBuf;
let mut db_path = PathBuf::from(data_path); let mut db_path = PathBuf::from(data_path);
@ -68,7 +68,7 @@ pub fn open_secretstore_db(data_path: &str) -> Result<Arc<KeyValueDB>, String> {
} }
/// Create a restoration db handler using the config generated by `client_path` and `client_config`. /// Create a restoration db handler using the config generated by `client_path` and `client_config`.
pub fn restoration_db_handler(client_path: &Path, client_config: &ClientConfig) -> Box<BlockChainDBHandler> { pub fn restoration_db_handler(client_path: &Path, client_config: &ClientConfig) -> Box<dyn BlockChainDBHandler> {
let client_db_config = helpers::client_db_config(client_path, client_config); let client_db_config = helpers::client_db_config(client_path, client_config);
struct RestorationDBHandler { struct RestorationDBHandler {
@ -76,7 +76,7 @@ pub fn restoration_db_handler(client_path: &Path, client_config: &ClientConfig)
} }
impl BlockChainDBHandler for RestorationDBHandler { impl BlockChainDBHandler for RestorationDBHandler {
fn open(&self, db_path: &Path) -> io::Result<Arc<BlockChainDB>> { fn open(&self, db_path: &Path) -> io::Result<Arc<dyn BlockChainDB>> {
open_database(&db_path.to_string_lossy(), &self.config) open_database(&db_path.to_string_lossy(), &self.config)
} }
} }
@ -87,7 +87,11 @@ pub fn restoration_db_handler(client_path: &Path, client_config: &ClientConfig)
} }
/// Open a new main DB. /// Open a new main DB.
pub fn open_db(client_path: &str, cache_config: &CacheConfig, compaction: &DatabaseCompactionProfile) -> io::Result<Arc<BlockChainDB>> { pub fn open_db(
client_path: &str,
cache_config: &CacheConfig,
compaction: &DatabaseCompactionProfile
) -> io::Result<Arc<dyn BlockChainDB>> {
let path = Path::new(client_path); let path = Path::new(client_path);
let db_config = DatabaseConfig { let db_config = DatabaseConfig {
@ -99,7 +103,7 @@ pub fn open_db(client_path: &str, cache_config: &CacheConfig, compaction: &Datab
open_database(client_path, &db_config) open_database(client_path, &db_config)
} }
pub fn open_database(client_path: &str, config: &DatabaseConfig) -> io::Result<Arc<BlockChainDB>> { pub fn open_database(client_path: &str, config: &DatabaseConfig) -> io::Result<Arc<dyn BlockChainDB>> {
let path = Path::new(client_path); let path = Path::new(client_path);
let blooms_path = path.join("blooms"); let blooms_path = path.join("blooms");

View File

@ -124,8 +124,8 @@ pub trait InformantData: Send + Sync {
/// Informant data for a full node. /// Informant data for a full node.
pub struct FullNodeInformantData { pub struct FullNodeInformantData {
pub client: Arc<Client>, pub client: Arc<Client>,
pub sync: Option<Arc<SyncProvider>>, pub sync: Option<Arc<dyn SyncProvider>>,
pub net: Option<Arc<ManageNetwork>>, pub net: Option<Arc<dyn ManageNetwork>>,
} }
impl InformantData for FullNodeInformantData { impl InformantData for FullNodeInformantData {
@ -180,7 +180,7 @@ impl InformantData for FullNodeInformantData {
/// Informant data for a light node -- note that the network is required. /// Informant data for a light node -- note that the network is required.
pub struct LightNodeInformantData { pub struct LightNodeInformantData {
pub client: Arc<LightChainClient>, pub client: Arc<dyn LightChainClient>,
pub sync: Arc<LightSync>, pub sync: Arc<LightSync>,
pub cache: Arc<Mutex<LightDataCache>>, pub cache: Arc<Mutex<LightDataCache>>,
} }

View File

@ -40,7 +40,7 @@ impl Default for Configuration {
} }
} }
pub fn start_server(conf: Configuration, client: Arc<BlockChainClient>) -> Result<Option<Listening>, ServerError> { pub fn start_server(conf: Configuration, client: Arc<dyn BlockChainClient>) -> Result<Option<Listening>, ServerError> {
if !conf.enabled { if !conf.enabled {
return Ok(None); return Ok(None);
} }

View File

@ -35,7 +35,7 @@ use ethereum_types::H256;
const ALL_VALID_BACKREFS: &str = "no back-references, therefore all back-references valid; qed"; const ALL_VALID_BACKREFS: &str = "no back-references, therefore all back-references valid; qed";
type BoxFuture<T, E> = Box<Future<Item = T, Error = E>>; type BoxFuture<T, E> = Box<dyn Future<Item = T, Error = E>>;
/// Allows on-demand fetch of data useful for the light client. /// Allows on-demand fetch of data useful for the light client.
pub struct EpochFetch { pub struct EpochFetch {
@ -83,7 +83,7 @@ impl ChainDataFetcher for EpochFetch {
} }
/// Fetch epoch transition proof at given header. /// Fetch epoch transition proof at given header.
fn epoch_transition(&self, hash: H256, engine: Arc<Engine>, checker: Arc<StateDependentProof>) fn epoch_transition(&self, hash: H256, engine: Arc<dyn Engine>, checker: Arc<dyn StateDependentProof>)
-> Self::Transition -> Self::Transition
{ {
self.request(request::Signal { self.request(request::Signal {

View File

@ -28,9 +28,9 @@ pub use ethcore::client::ChainNotify;
use ethcore_logger::Config as LogConfig; use ethcore_logger::Config as LogConfig;
pub type SyncModules = ( pub type SyncModules = (
Arc<SyncProvider>, Arc<dyn SyncProvider>,
Arc<ManageNetwork>, Arc<dyn ManageNetwork>,
Arc<ChainNotify>, Arc<dyn ChainNotify>,
mpsc::Sender<sync::PriorityTask>, mpsc::Sender<sync::PriorityTask>,
); );
@ -38,13 +38,13 @@ pub fn sync(
config: SyncConfig, config: SyncConfig,
executor: Executor, executor: Executor,
network_config: NetworkConfiguration, network_config: NetworkConfiguration,
chain: Arc<BlockChainClient>, chain: Arc<dyn BlockChainClient>,
snapshot_service: Arc<SnapshotService>, snapshot_service: Arc<dyn SnapshotService>,
private_tx_handler: Option<Arc<PrivateTxHandler>>, private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
private_state: Option<Arc<PrivateStateDB>>, private_state: Option<Arc<PrivateStateDB>>,
provider: Arc<Provider>, provider: Arc<dyn Provider>,
_log_settings: &LogConfig, _log_settings: &LogConfig,
connection_filter: Option<Arc<ConnectionFilter>>, connection_filter: Option<Arc<dyn ConnectionFilter>>,
) -> Result<SyncModules, sync::Error> { ) -> Result<SyncModules, sync::Error> {
let eth_sync = EthSync::new(Params { let eth_sync = EthSync::new(Params {
config, config,
@ -59,9 +59,9 @@ pub fn sync(
connection_filter)?; connection_filter)?;
Ok(( Ok((
eth_sync.clone() as Arc<SyncProvider>, eth_sync.clone() as Arc<dyn SyncProvider>,
eth_sync.clone() as Arc<ManageNetwork>, eth_sync.clone() as Arc<dyn ManageNetwork>,
eth_sync.clone() as Arc<ChainNotify>, eth_sync.clone() as Arc<dyn ChainNotify>,
eth_sync.priority_tasks() eth_sync.priority_tasks()
)) ))
} }

View File

@ -235,16 +235,16 @@ pub trait Dependencies {
pub struct FullDependencies { pub struct FullDependencies {
pub signer_service: Arc<SignerService>, pub signer_service: Arc<SignerService>,
pub client: Arc<Client>, pub client: Arc<Client>,
pub snapshot: Arc<SnapshotService>, pub snapshot: Arc<dyn SnapshotService>,
pub sync: Arc<SyncProvider>, pub sync: Arc<dyn SyncProvider>,
pub net: Arc<ManageNetwork>, pub net: Arc<dyn ManageNetwork>,
pub accounts: Arc<AccountProvider>, pub accounts: Arc<AccountProvider>,
pub private_tx_service: Option<Arc<PrivateTxService>>, pub private_tx_service: Option<Arc<PrivateTxService>>,
pub miner: Arc<Miner>, pub miner: Arc<Miner>,
pub external_miner: Arc<ExternalMiner>, pub external_miner: Arc<ExternalMiner>,
pub logger: Arc<RotatingLogger>, pub logger: Arc<RotatingLogger>,
pub settings: Arc<NetworkSettings>, pub settings: Arc<NetworkSettings>,
pub net_service: Arc<ManageNetwork>, pub net_service: Arc<dyn ManageNetwork>,
pub updater: Arc<Updater>, pub updater: Arc<Updater>,
pub geth_compatibility: bool, pub geth_compatibility: bool,
pub experimental_rpcs: bool, pub experimental_rpcs: bool,
@ -485,7 +485,7 @@ pub struct LightDependencies<T> {
pub signer_service: Arc<SignerService>, pub signer_service: Arc<SignerService>,
pub client: Arc<T>, pub client: Arc<T>,
pub sync: Arc<LightSync>, pub sync: Arc<LightSync>,
pub net: Arc<ManageNetwork>, pub net: Arc<dyn ManageNetwork>,
pub accounts: Arc<AccountProvider>, pub accounts: Arc<AccountProvider>,
pub logger: Arc<RotatingLogger>, pub logger: Arc<RotatingLogger>,
pub settings: Arc<NetworkSettings>, pub settings: Arc<NetworkSettings>,

View File

@ -583,7 +583,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
// take handle to private transactions service // take handle to private transactions service
let private_tx_service = service.private_tx_service(); let private_tx_service = service.private_tx_service();
let private_tx_provider = private_tx_service.provider(); let private_tx_provider = private_tx_service.provider();
let connection_filter = connection_filter_address.map(|a| Arc::new(NodeFilter::new(Arc::downgrade(&client) as Weak<BlockChainClient>, a))); let connection_filter = connection_filter_address.map(|a| Arc::new(NodeFilter::new(Arc::downgrade(&client) as Weak<dyn BlockChainClient>, a)));
let snapshot_service = service.snapshot_service(); let snapshot_service = service.snapshot_service();
if let Some(filter) = connection_filter.clone() { if let Some(filter) = connection_filter.clone() {
service.add_notify(filter.clone()); service.add_notify(filter.clone());
@ -636,7 +636,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
} }
let (private_tx_sync, private_state) = match cmd.private_tx_enabled { let (private_tx_sync, private_state) = match cmd.private_tx_enabled {
true => (Some(private_tx_service.clone() as Arc<PrivateTxHandler>), Some(private_tx_provider.private_state_db())), true => (Some(private_tx_service.clone() as Arc<dyn PrivateTxHandler>), Some(private_tx_provider.private_state_db())),
false => (None, None), false => (None, None),
}; };
@ -651,7 +651,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
private_state, private_state,
client.clone(), client.clone(),
&cmd.logger_config, &cmd.logger_config,
connection_filter.clone().map(|f| f as Arc<::sync::ConnectionFilter + 'static>), connection_filter.clone().map(|f| f as Arc<dyn sync::ConnectionFilter + 'static>),
).map_err(|e| format!("Sync error: {}", e))?; ).map_err(|e| format!("Sync error: {}", e))?;
service.add_notify(chain_notify.clone()); service.add_notify(chain_notify.clone());
@ -706,7 +706,7 @@ fn execute_impl<Cr, Rr>(cmd: RunCmd, logger: Arc<RotatingLogger>, on_client_rq:
// the updater service // the updater service
let updater_fetch = fetch.clone(); let updater_fetch = fetch.clone();
let updater = Updater::new( let updater = Updater::new(
&Arc::downgrade(&(service.client() as Arc<BlockChainClient>)), &Arc::downgrade(&(service.client() as Arc<dyn BlockChainClient>)),
&Arc::downgrade(&sync_provider), &Arc::downgrade(&sync_provider),
update_policy, update_policy,
hash_fetch::Client::with_fetch(contract_client.clone(), updater_fetch, runtime.executor()) hash_fetch::Client::with_fetch(contract_client.clone(), updater_fetch, runtime.executor())
@ -843,14 +843,14 @@ enum RunningClientInner {
rpc: jsonrpc_core::MetaIoHandler<Metadata, informant::Middleware<rpc_apis::LightClientNotifier>>, rpc: jsonrpc_core::MetaIoHandler<Metadata, informant::Middleware<rpc_apis::LightClientNotifier>>,
informant: Arc<Informant<LightNodeInformantData>>, informant: Arc<Informant<LightNodeInformantData>>,
client: Arc<LightClient>, client: Arc<LightClient>,
keep_alive: Box<Any>, keep_alive: Box<dyn Any>,
}, },
Full { Full {
rpc: jsonrpc_core::MetaIoHandler<Metadata, informant::Middleware<informant::ClientNotifier>>, rpc: jsonrpc_core::MetaIoHandler<Metadata, informant::Middleware<informant::ClientNotifier>>,
informant: Arc<Informant<FullNodeInformantData>>, informant: Arc<Informant<FullNodeInformantData>>,
client: Arc<Client>, client: Arc<Client>,
client_service: Arc<ClientService>, client_service: Arc<ClientService>,
keep_alive: Box<Any>, keep_alive: Box<dyn Any>,
}, },
} }

View File

@ -93,7 +93,7 @@ pub struct Dependencies<'a> {
/// Blockchain client. /// Blockchain client.
pub client: Arc<Client>, pub client: Arc<Client>,
/// Sync provider. /// Sync provider.
pub sync: Arc<SyncProvider>, pub sync: Arc<dyn SyncProvider>,
/// Miner service. /// Miner service.
pub miner: Arc<Miner>, pub miner: Arc<Miner>,
/// Account provider. /// Account provider.

View File

@ -64,7 +64,6 @@ parity-updater = { path = "../updater" }
parity-version = { path = "../util/version" } parity-version = { path = "../util/version" }
rlp = "0.4.0" rlp = "0.4.0"
account-state = { path = "../ethcore/account-state" } account-state = { path = "../ethcore/account-state" }
spec = { path = "../ethcore/spec" }
stats = { path = "../util/stats" } stats = { path = "../util/stats" }
trace = { path = "../ethcore/trace" } trace = { path = "../ethcore/trace" }
vm = { path = "../ethcore/vm" } vm = { path = "../ethcore/vm" }
@ -77,6 +76,7 @@ ethcore-io = { path = "../util/io" }
ethcore-network = { path = "../util/network" } ethcore-network = { path = "../util/network" }
fake-fetch = { path = "../util/fake-fetch" } fake-fetch = { path = "../util/fake-fetch" }
macros = { path = "../util/macros" } macros = { path = "../util/macros" }
spec = { path = "../ethcore/spec" }
pretty_assertions = "0.1" pretty_assertions = "0.1"
transaction-pool = "2.0" transaction-pool = "2.0"

View File

@ -85,7 +85,7 @@ extern crate parity_version as version;
extern crate eip_712; extern crate eip_712;
extern crate rlp; extern crate rlp;
extern crate account_state; extern crate account_state;
extern crate spec;
extern crate stats; extern crate stats;
extern crate tempdir; extern crate tempdir;
extern crate trace; extern crate trace;
@ -127,6 +127,9 @@ extern crate fake_fetch;
#[cfg(test)] #[cfg(test)]
extern crate ethcore_io as io; extern crate ethcore_io as io;
#[cfg(test)]
extern crate spec;
pub extern crate jsonrpc_ws_server as ws; pub extern crate jsonrpc_ws_server as ws;
mod authcodes; mod authcodes;

View File

@ -38,7 +38,7 @@ const PRINT_INTERVAL: Duration = Duration::from_secs(60);
pub struct DeprecationNotice<T = fn() -> Instant> { pub struct DeprecationNotice<T = fn() -> Instant> {
now: T, now: T,
next_warning_at: RwLock<HashMap<String, Instant>>, next_warning_at: RwLock<HashMap<String, Instant>>,
printer: Box<Fn(MethodName, Option<&str>) + Send + Sync>, printer: Box<dyn Fn(MethodName, Option<&str>) + Send + Sync>,
} }
impl Default for DeprecationNotice { impl Default for DeprecationNotice {

View File

@ -118,7 +118,7 @@ impl<C: miner::BlockChainClient + BlockChainClient, M: MinerService> Dispatcher
fn sign<P>( fn sign<P>(
&self, &self,
filled: FilledTransactionRequest, filled: FilledTransactionRequest,
signer: &Arc<Accounts>, signer: &Arc<dyn Accounts>,
password: SignWith, password: SignWith,
post_sign: P, post_sign: P,
) -> BoxFuture<P::Item> ) -> BoxFuture<P::Item>

View File

@ -45,7 +45,7 @@ where
/// Sync service. /// Sync service.
pub sync: Arc<S>, pub sync: Arc<S>,
/// Header chain client. /// Header chain client.
pub client: Arc<LightChainClient>, pub client: Arc<dyn LightChainClient>,
/// On-demand request service. /// On-demand request service.
pub on_demand: Arc<OD>, pub on_demand: Arc<OD>,
/// Data cache. /// Data cache.
@ -68,7 +68,7 @@ where
/// For correct operation, the OnDemand service is assumed to be registered as a network handler, /// For correct operation, the OnDemand service is assumed to be registered as a network handler,
pub fn new( pub fn new(
sync: Arc<S>, sync: Arc<S>,
client: Arc<LightChainClient>, client: Arc<dyn LightChainClient>,
on_demand: Arc<OD>, on_demand: Arc<OD>,
cache: Arc<Mutex<LightDataCache>>, cache: Arc<Mutex<LightDataCache>>,
transaction_queue: Arc<RwLock<LightTransactionQueue>>, transaction_queue: Arc<RwLock<LightTransactionQueue>>,
@ -215,7 +215,7 @@ where
fn sign<P>( fn sign<P>(
&self, &self,
filled: FilledTransactionRequest, filled: FilledTransactionRequest,
signer: &Arc<Accounts>, signer: &Arc<dyn Accounts>,
password: SignWith, password: SignWith,
post_sign: P post_sign: P
) -> BoxFuture<P::Item> ) -> BoxFuture<P::Item>
@ -248,7 +248,7 @@ where
// TODO: this could be `impl Trait`. // TODO: this could be `impl Trait`.
pub fn fetch_gas_price_corpus<S, OD>( pub fn fetch_gas_price_corpus<S, OD>(
sync: Arc<S>, sync: Arc<S>,
client: Arc<LightChainClient>, client: Arc<dyn LightChainClient>,
on_demand: Arc<OD>, on_demand: Arc<OD>,
cache: Arc<Mutex<LightDataCache>>, cache: Arc<Mutex<LightDataCache>>,
) -> BoxFuture<Corpus<U256>> ) -> BoxFuture<Corpus<U256>>

View File

@ -111,7 +111,7 @@ pub trait Dispatcher: Send + Sync + Clone {
fn sign<P>( fn sign<P>(
&self, &self,
filled: FilledTransactionRequest, filled: FilledTransactionRequest,
signer: &Arc<Accounts>, signer: &Arc<dyn Accounts>,
password: SignWith, password: SignWith,
post_sign: P, post_sign: P,
) -> BoxFuture<P::Item> where ) -> BoxFuture<P::Item> where
@ -277,7 +277,7 @@ impl<T: Debug> From<(T, Option<AccountToken>)> for WithToken<T> {
/// Execute a confirmation payload. /// Execute a confirmation payload.
pub fn execute<D: Dispatcher + 'static>( pub fn execute<D: Dispatcher + 'static>(
dispatcher: D, dispatcher: D,
signer: &Arc<Accounts>, signer: &Arc<dyn Accounts>,
payload: ConfirmationPayload, payload: ConfirmationPayload,
pass: SignWith pass: SignWith
) -> BoxFuture<WithToken<ConfirmationResponse>> { ) -> BoxFuture<WithToken<ConfirmationResponse>> {

View File

@ -32,7 +32,7 @@ enum ProspectiveSignerState {
} }
pub struct ProspectiveSigner<P: PostSign> { pub struct ProspectiveSigner<P: PostSign> {
signer: Arc<Accounts>, signer: Arc<dyn Accounts>,
filled: FilledTransactionRequest, filled: FilledTransactionRequest,
chain_id: Option<u64>, chain_id: Option<u64>,
reserved: nonce::Reserved, reserved: nonce::Reserved,
@ -46,7 +46,7 @@ pub struct ProspectiveSigner<P: PostSign> {
impl<P: PostSign> ProspectiveSigner<P> { impl<P: PostSign> ProspectiveSigner<P> {
pub fn new( pub fn new(
signer: Arc<Accounts>, signer: Arc<dyn Accounts>,
filled: FilledTransactionRequest, filled: FilledTransactionRequest,
chain_id: Option<u64>, chain_id: Option<u64>,
reserved: nonce::Reserved, reserved: nonce::Reserved,

View File

@ -30,7 +30,7 @@ pub use self::signing_queue::QueueEvent;
pub struct SignerService { pub struct SignerService {
is_enabled: bool, is_enabled: bool,
queue: Arc<ConfirmationsQueue>, queue: Arc<ConfirmationsQueue>,
generate_new_token: Box<Fn() -> Result<String, String> + Send + Sync + 'static>, generate_new_token: Box<dyn Fn() -> Result<String, String> + Send + Sync + 'static>,
} }
impl SignerService { impl SignerService {

View File

@ -96,7 +96,7 @@ pub type ConfirmationReceiver = oneshot::Receiver<ConfirmationResult>;
pub struct ConfirmationsQueue { pub struct ConfirmationsQueue {
id: Mutex<U256>, id: Mutex<U256>,
queue: RwLock<BTreeMap<U256, ConfirmationSender>>, queue: RwLock<BTreeMap<U256, ConfirmationSender>>,
on_event: RwLock<Vec<Box<Fn(QueueEvent) -> () + Send + Sync>>>, on_event: RwLock<Vec<Box<dyn Fn(QueueEvent) -> () + Send + Sync>>>,
} }
impl ConfirmationsQueue { impl ConfirmationsQueue {

View File

@ -82,7 +82,7 @@ where
OD: OnDemandRequester + 'static OD: OnDemandRequester + 'static
{ {
/// The light client. /// The light client.
pub client: Arc<LightChainClient>, pub client: Arc<dyn LightChainClient>,
/// The on-demand request service. /// The on-demand request service.
pub on_demand: Arc<OD>, pub on_demand: Arc<OD>,
/// Handle to the network. /// Handle to the network.
@ -585,7 +585,7 @@ where
match maybe_future { match maybe_future {
Some(recv) => recv, Some(recv) => recv,
None => Box::new(future::err(errors::network_disabled())) as Box<Future<Item = _, Error = _> + Send> None => Box::new(future::err(errors::network_disabled())) as Box<dyn Future<Item = _, Error = _> + Send>
} }
} }
@ -741,7 +741,7 @@ where
tx: EthTransaction, tx: EthTransaction,
hdr: encoded::Header, hdr: encoded::Header,
env_info: ::vm::EnvInfo, env_info: ::vm::EnvInfo,
engine: Arc<engine::Engine>, engine: Arc<dyn engine::Engine>,
on_demand: Arc<OD>, on_demand: Arc<OD>,
sync: Arc<S>, sync: Arc<S>,
} }
@ -806,7 +806,7 @@ where
failed => Ok(future::Loop::Break(failed)), failed => Ok(future::Loop::Break(failed)),
} }
}) })
})) as Box<Future<Item = _, Error = _> + Send> })) as Box<dyn Future<Item = _, Error = _> + Send>
} else { } else {
trace!(target: "light_fetch", "Placing execution request for {} gas in on_demand", trace!(target: "light_fetch", "Placing execution request for {} gas in on_demand",
params.tx.gas); params.tx.gas);
@ -827,8 +827,8 @@ where
}); });
match proved_future { match proved_future {
Some(fut) => Box::new(fut) as Box<Future<Item = _, Error = _> + Send>, Some(fut) => Box::new(fut) as Box<dyn Future<Item = _, Error = _> + Send>,
None => Box::new(future::err(errors::network_disabled())) as Box<Future<Item = _, Error = _> + Send>, None => Box::new(future::err(errors::network_disabled())) as Box<dyn Future<Item = _, Error = _> + Send>,
} }
} }
} }

View File

@ -87,7 +87,7 @@ impl<S: core::Middleware<Metadata>> GenericPollManager<S> {
}).is_some() }).is_some()
} }
pub fn tick(&self) -> Box<Future<Item=(), Error=()> + Send> { pub fn tick(&self) -> Box<dyn Future<Item=(), Error=()> + Send> {
let mut futures = Vec::new(); let mut futures = Vec::new();
// poll all subscriptions // poll all subscriptions
for (id, subscription) in self.subscribers.iter() { for (id, subscription) in self.subscribers.iter() {

View File

@ -113,7 +113,7 @@ pub struct EthClient<C, SN: ?Sized, S: ?Sized, M, EM> where
client: Arc<C>, client: Arc<C>,
snapshot: Arc<SN>, snapshot: Arc<SN>,
sync: Arc<S>, sync: Arc<S>,
accounts: Arc<Fn() -> Vec<Address> + Send + Sync>, accounts: Arc<dyn Fn() -> Vec<Address> + Send + Sync>,
miner: Arc<M>, miner: Arc<M>,
external_miner: Arc<EM>, external_miner: Arc<EM>,
seed_compute: Mutex<SeedHashCompute>, seed_compute: Mutex<SeedHashCompute>,
@ -193,7 +193,7 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S
client: &Arc<C>, client: &Arc<C>,
snapshot: &Arc<SN>, snapshot: &Arc<SN>,
sync: &Arc<S>, sync: &Arc<S>,
accounts: &Arc<Fn() -> Vec<Address> + Send + Sync>, accounts: &Arc<dyn Fn() -> Vec<Address> + Send + Sync>,
miner: &Arc<M>, miner: &Arc<M>,
em: &Arc<EM>, em: &Arc<EM>,
options: EthClientOptions options: EthClientOptions
@ -449,8 +449,8 @@ impl<C, SN: ?Sized, S: ?Sized, M, EM, T: StateInfo + 'static> EthClient<C, SN, S
self.miner self.miner
.pending_state(info.best_block_number) .pending_state(info.best_block_number)
.map(|s| Box::new(s) as Box<StateInfo>) .map(|s| Box::new(s) as Box<dyn StateInfo>)
.unwrap_or(Box::new(self.client.latest_state()) as Box<StateInfo>) .unwrap_or(Box::new(self.client.latest_state()) as Box<dyn StateInfo>)
.into() .into()
} }
} }

View File

@ -137,7 +137,7 @@ where
{ {
/// Creates a new `EthPubSubClient` for `LightClient`. /// Creates a new `EthPubSubClient` for `LightClient`.
pub fn light( pub fn light(
client: Arc<LightChainClient>, client: Arc<dyn LightChainClient>,
on_demand: Arc<OD>, on_demand: Arc<OD>,
sync: Arc<S>, sync: Arc<S>,
cache: Arc<Mutex<Cache>>, cache: Arc<Mutex<Cache>>,

View File

@ -58,7 +58,7 @@ pub struct EthClient<C, S: LightSyncProvider + LightNetworkDispatcher + 'static,
client: Arc<C>, client: Arc<C>,
on_demand: Arc<OD>, on_demand: Arc<OD>,
transaction_queue: Arc<RwLock<TransactionQueue>>, transaction_queue: Arc<RwLock<TransactionQueue>>,
accounts: Arc<Fn() -> Vec<Address> + Send + Sync>, accounts: Arc<dyn Fn() -> Vec<Address> + Send + Sync>,
cache: Arc<Mutex<LightDataCache>>, cache: Arc<Mutex<LightDataCache>>,
polls: Mutex<PollManager<SyncPollFilter>>, polls: Mutex<PollManager<SyncPollFilter>>,
poll_lifetime: u32, poll_lifetime: u32,
@ -101,7 +101,7 @@ where
client: Arc<C>, client: Arc<C>,
on_demand: Arc<OD>, on_demand: Arc<OD>,
transaction_queue: Arc<RwLock<TransactionQueue>>, transaction_queue: Arc<RwLock<TransactionQueue>>,
accounts: Arc<Fn() -> Vec<Address> + Send + Sync>, accounts: Arc<dyn Fn() -> Vec<Address> + Send + Sync>,
cache: Arc<Mutex<LightDataCache>>, cache: Arc<Mutex<LightDataCache>>,
gas_price_percentile: usize, gas_price_percentile: usize,
poll_lifetime: u32 poll_lifetime: u32

View File

@ -34,14 +34,14 @@ use v1::types::{Bytes, ReleaseInfo, Transaction};
/// Parity-specific rpc interface for operations altering the settings. /// Parity-specific rpc interface for operations altering the settings.
pub struct ParitySetClient<F> { pub struct ParitySetClient<F> {
client: Arc<LightChainClient>, client: Arc<dyn LightChainClient>,
net: Arc<ManageNetwork>, net: Arc<dyn ManageNetwork>,
fetch: F, fetch: F,
} }
impl<F: Fetch> ParitySetClient<F> { impl<F: Fetch> ParitySetClient<F> {
/// Creates new `ParitySetClient` with given `Fetch`. /// Creates new `ParitySetClient` with given `Fetch`.
pub fn new(client: Arc<LightChainClient>, net: Arc<ManageNetwork>, fetch: F) -> Self { pub fn new(client: Arc<dyn LightChainClient>, net: Arc<dyn ManageNetwork>, fetch: F) -> Self {
ParitySetClient { ParitySetClient {
client, client,
net, net,

View File

@ -59,13 +59,13 @@ pub struct ParityClient<C, M, U> {
client: Arc<C>, client: Arc<C>,
miner: Arc<M>, miner: Arc<M>,
updater: Arc<U>, updater: Arc<U>,
sync: Arc<SyncProvider>, sync: Arc<dyn SyncProvider>,
net: Arc<ManageNetwork>, net: Arc<dyn ManageNetwork>,
logger: Arc<RotatingLogger>, logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>, settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>, signer: Option<Arc<SignerService>>,
ws_address: Option<Host>, ws_address: Option<Host>,
snapshot: Option<Arc<SnapshotService>>, snapshot: Option<Arc<dyn SnapshotService>>,
} }
impl<C, M, U> ParityClient<C, M, U> where impl<C, M, U> ParityClient<C, M, U> where
@ -75,14 +75,14 @@ impl<C, M, U> ParityClient<C, M, U> where
pub fn new( pub fn new(
client: Arc<C>, client: Arc<C>,
miner: Arc<M>, miner: Arc<M>,
sync: Arc<SyncProvider>, sync: Arc<dyn SyncProvider>,
updater: Arc<U>, updater: Arc<U>,
net: Arc<ManageNetwork>, net: Arc<dyn ManageNetwork>,
logger: Arc<RotatingLogger>, logger: Arc<RotatingLogger>,
settings: Arc<NetworkSettings>, settings: Arc<NetworkSettings>,
signer: Option<Arc<SignerService>>, signer: Option<Arc<SignerService>>,
ws_address: Option<Host>, ws_address: Option<Host>,
snapshot: Option<Arc<SnapshotService>>, snapshot: Option<Arc<dyn SnapshotService>>,
) -> Self { ) -> Self {
ParityClient { ParityClient {
client, client,

View File

@ -87,7 +87,7 @@ pub struct ParitySetClient<C, M, U, F = fetch::Client> {
client: Arc<C>, client: Arc<C>,
miner: Arc<M>, miner: Arc<M>,
updater: Arc<U>, updater: Arc<U>,
net: Arc<ManageNetwork>, net: Arc<dyn ManageNetwork>,
fetch: F, fetch: F,
} }
@ -99,7 +99,7 @@ impl<C, M, U, F> ParitySetClient<C, M, U, F>
client: &Arc<C>, client: &Arc<C>,
miner: &Arc<M>, miner: &Arc<M>,
updater: &Arc<U>, updater: &Arc<U>,
net: &Arc<ManageNetwork>, net: &Arc<dyn ManageNetwork>,
fetch: F, fetch: F,
) -> Self { ) -> Self {
ParitySetClient { ParitySetClient {

View File

@ -40,7 +40,7 @@ use v1::types::{TransactionModification, ConfirmationRequest, ConfirmationRespon
/// Transactions confirmation (personal) rpc implementation. /// Transactions confirmation (personal) rpc implementation.
pub struct SignerClient<D: Dispatcher> { pub struct SignerClient<D: Dispatcher> {
signer: Arc<SignerService>, signer: Arc<SignerService>,
accounts: Arc<dispatch::Accounts>, accounts: Arc<dyn dispatch::Accounts>,
dispatcher: D, dispatcher: D,
subscribers: Arc<Mutex<Subscribers<Sink<Vec<ConfirmationRequest>>>>>, subscribers: Arc<Mutex<Subscribers<Sink<Vec<ConfirmationRequest>>>>>,
deprecation_notice: DeprecationNotice, deprecation_notice: DeprecationNotice,
@ -49,7 +49,7 @@ pub struct SignerClient<D: Dispatcher> {
impl<D: Dispatcher + 'static> SignerClient<D> { impl<D: Dispatcher + 'static> SignerClient<D> {
/// Create new instance of signer client. /// Create new instance of signer client.
pub fn new( pub fn new(
accounts: Arc<dispatch::Accounts>, accounts: Arc<dyn dispatch::Accounts>,
dispatcher: D, dispatcher: D,
signer: &Arc<SignerService>, signer: &Arc<SignerService>,
executor: Executor, executor: Executor,
@ -81,7 +81,7 @@ impl<D: Dispatcher + 'static> SignerClient<D> {
} }
fn confirm_internal<F, T>(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture<WithToken<ConfirmationResponse>> where fn confirm_internal<F, T>(&self, id: U256, modification: TransactionModification, f: F) -> BoxFuture<WithToken<ConfirmationResponse>> where
F: FnOnce(D, &Arc<dispatch::Accounts>, ConfirmationPayload) -> T, F: FnOnce(D, &Arc<dyn dispatch::Accounts>, ConfirmationPayload) -> T,
T: IntoFuture<Item=WithToken<ConfirmationResponse>, Error=Error>, T: IntoFuture<Item=WithToken<ConfirmationResponse>, Error=Error>,
T::Future: Send + 'static T::Future: Send + 'static
{ {

View File

@ -91,7 +91,7 @@ fn schedule(executor: Executor,
/// Implementation of functions that require signing when no trusted signer is used. /// Implementation of functions that require signing when no trusted signer is used.
pub struct SigningQueueClient<D> { pub struct SigningQueueClient<D> {
signer: Arc<SignerService>, signer: Arc<SignerService>,
accounts: Arc<dispatch::Accounts>, accounts: Arc<dyn dispatch::Accounts>,
dispatcher: D, dispatcher: D,
executor: Executor, executor: Executor,
// None here means that the request hasn't yet been confirmed // None here means that the request hasn't yet been confirmed
@ -101,7 +101,7 @@ pub struct SigningQueueClient<D> {
impl<D: Dispatcher + 'static> SigningQueueClient<D> { impl<D: Dispatcher + 'static> SigningQueueClient<D> {
/// Creates a new signing queue client given shared signing queue. /// Creates a new signing queue client given shared signing queue.
pub fn new(signer: &Arc<SignerService>, dispatcher: D, executor: Executor, accounts: &Arc<dispatch::Accounts>) -> Self { pub fn new(signer: &Arc<SignerService>, dispatcher: D, executor: Executor, accounts: &Arc<dyn dispatch::Accounts>) -> Self {
SigningQueueClient { SigningQueueClient {
signer: signer.clone(), signer: signer.clone(),
accounts: accounts.clone(), accounts: accounts.clone(),

View File

@ -37,14 +37,14 @@ use v1::types::{
/// Implementation of functions that require signing when no trusted signer is used. /// Implementation of functions that require signing when no trusted signer is used.
pub struct SigningUnsafeClient<D> { pub struct SigningUnsafeClient<D> {
accounts: Arc<dispatch::Accounts>, accounts: Arc<dyn dispatch::Accounts>,
dispatcher: D, dispatcher: D,
deprecation_notice: DeprecationNotice, deprecation_notice: DeprecationNotice,
} }
impl<D: Dispatcher + 'static> SigningUnsafeClient<D> { impl<D: Dispatcher + 'static> SigningUnsafeClient<D> {
/// Creates new SigningUnsafeClient. /// Creates new SigningUnsafeClient.
pub fn new(accounts: &Arc<dispatch::Accounts>, dispatcher: D) -> Self { pub fn new(accounts: &Arc<dyn dispatch::Accounts>, dispatcher: D) -> Self {
SigningUnsafeClient { SigningUnsafeClient {
accounts: accounts.clone(), accounts: accounts.clone(),
dispatcher, dispatcher,

View File

@ -55,7 +55,7 @@ pub struct TestMinerService {
/// Minimum gas price /// Minimum gas price
pub min_gas_price: RwLock<Option<U256>>, pub min_gas_price: RwLock<Option<U256>>,
/// Signer (if any) /// Signer (if any)
pub signer: RwLock<Option<Box<EngineSigner>>>, pub signer: RwLock<Option<Box<dyn EngineSigner>>>,
authoring_params: RwLock<AuthoringParams>, authoring_params: RwLock<AuthoringParams>,
} }
@ -102,7 +102,7 @@ impl StateClient for TestMinerService {
} }
impl EngineInfo for TestMinerService { impl EngineInfo for TestMinerService {
fn engine(&self) -> &Engine { fn engine(&self) -> &dyn Engine {
unimplemented!() unimplemented!()
} }
} }

View File

@ -31,5 +31,5 @@ impl ManageNetwork for TestManageNetwork {
fn start_network(&self) {} fn start_network(&self) {}
fn stop_network(&self) {} fn stop_network(&self) {}
fn num_peers_range(&self) -> RangeInclusive<u32> { 25..=50 } fn num_peers_range(&self) -> RangeInclusive<u32> { 25..=50 }
fn with_proto_context(&self, _: ProtocolId, _: &mut FnMut(&NetworkContext)) { } fn with_proto_context(&self, _: ProtocolId, _: &mut dyn FnMut(&dyn NetworkContext)) { }
} }

View File

@ -45,7 +45,7 @@ pub struct Dependencies {
pub updater: Arc<TestUpdater>, pub updater: Arc<TestUpdater>,
pub logger: Arc<RotatingLogger>, pub logger: Arc<RotatingLogger>,
pub settings: Arc<NetworkSettings>, pub settings: Arc<NetworkSettings>,
pub network: Arc<ManageNetwork>, pub network: Arc<dyn ManageNetwork>,
pub ws_address: Option<Host>, pub ws_address: Option<Host>,
} }

View File

@ -58,7 +58,7 @@ fn parity_set_client(
client, client,
miner, miner,
updater, updater,
&(net.clone() as Arc<ManageNetwork>), &(net.clone() as Arc<dyn ManageNetwork>),
FakeFetch::new(Some(1)), FakeFetch::new(Some(1)),
) )
} }

View File

@ -19,7 +19,7 @@ use serde::{Deserialize, Deserializer};
use serde::de::{Error, Visitor}; use serde::de::{Error, Visitor};
use ethereum_types::H256; use ethereum_types::H256;
use ethstore;
/// Type of derivation /// Type of derivation
pub enum DerivationType { pub enum DerivationType {

View File

@ -37,7 +37,7 @@ pub trait HashFetch: Send + Sync + 'static {
/// 2. `on_done` - callback function invoked when the content is ready (or there was error during fetch) /// 2. `on_done` - callback function invoked when the content is ready (or there was error during fetch)
/// ///
/// This function may fail immediately when fetch cannot be initialized or content cannot be resolved. /// This function may fail immediately when fetch cannot be initialized or content cannot be resolved.
fn fetch(&self, hash: H256, abort: fetch::Abort, on_done: Box<Fn(Result<PathBuf, Error>) + Send>); fn fetch(&self, hash: H256, abort: fetch::Abort, on_done: Box<dyn Fn(Result<PathBuf, Error>) + Send>);
} }
/// Hash-fetching error. /// Hash-fetching error.
@ -111,12 +111,12 @@ pub struct Client<F: Fetch + 'static = fetch::Client> {
contract: URLHintContract, contract: URLHintContract,
fetch: F, fetch: F,
executor: Executor, executor: Executor,
random_path: Arc<Fn() -> PathBuf + Sync + Send>, random_path: Arc<dyn Fn() -> PathBuf + Sync + Send>,
} }
impl<F: Fetch + 'static> Client<F> { impl<F: Fetch + 'static> Client<F> {
/// Creates new instance of the `Client` given on-chain contract client, fetch service and task runner. /// Creates new instance of the `Client` given on-chain contract client, fetch service and task runner.
pub fn with_fetch(contract: Arc<RegistrarClient<Call=Asynchronous>>, fetch: F, executor: Executor) -> Self { pub fn with_fetch(contract: Arc<dyn RegistrarClient<Call=Asynchronous>>, fetch: F, executor: Executor) -> Self {
Client { Client {
contract: URLHintContract::new(contract), contract: URLHintContract::new(contract),
fetch: fetch, fetch: fetch,
@ -127,7 +127,7 @@ impl<F: Fetch + 'static> Client<F> {
} }
impl<F: Fetch + 'static> HashFetch for Client<F> { impl<F: Fetch + 'static> HashFetch for Client<F> {
fn fetch(&self, hash: H256, abort: fetch::Abort, on_done: Box<Fn(Result<PathBuf, Error>) + Send>) { fn fetch(&self, hash: H256, abort: fetch::Abort, on_done: Box<dyn Fn(Result<PathBuf, Error>) + Send>) {
debug!(target: "fetch", "Fetching: {:?}", hash); debug!(target: "fetch", "Fetching: {:?}", hash);
let random_path = self.random_path.clone(); let random_path = self.random_path.clone();

View File

@ -35,7 +35,7 @@ extern crate registrar;
pub extern crate fetch; pub extern crate fetch;
#[macro_use] // #[macro_use]
extern crate ethabi_derive; extern crate ethabi_derive;
#[macro_use] #[macro_use]
extern crate ethabi_contract; extern crate ethabi_contract;

View File

@ -95,18 +95,18 @@ pub enum URLHintResult {
/// URLHint Contract interface /// URLHint Contract interface
pub trait URLHint: Send + Sync { pub trait URLHint: Send + Sync {
/// Resolves given id to registrar entry. /// Resolves given id to registrar entry.
fn resolve(&self, id: H256) -> Box<Future<Item = Option<URLHintResult>, Error = String> + Send>; fn resolve(&self, id: H256) -> Box<dyn Future<Item = Option<URLHintResult>, Error = String> + Send>;
} }
/// `URLHintContract` API /// `URLHintContract` API
pub struct URLHintContract { pub struct URLHintContract {
registrar: Registrar, registrar: Registrar,
client: Arc<RegistrarClient<Call=Asynchronous>>, client: Arc<dyn RegistrarClient<Call=Asynchronous>>,
} }
impl URLHintContract { impl URLHintContract {
/// Creates new `URLHintContract` /// Creates new `URLHintContract`
pub fn new(client: Arc<RegistrarClient<Call=Asynchronous>>) -> Self { pub fn new(client: Arc<dyn RegistrarClient<Call=Asynchronous>>) -> Self {
URLHintContract { URLHintContract {
registrar: Registrar::new(client.clone()), registrar: Registrar::new(client.clone()),
client: client, client: client,
@ -159,7 +159,7 @@ fn decode_urlhint_output(output: (String, [u8; 20], Address)) -> Option<URLHintR
} }
impl URLHint for URLHintContract { impl URLHint for URLHintContract {
fn resolve(&self, id: H256) -> Box<Future<Item = Option<URLHintResult>, Error = String> + Send> { fn resolve(&self, id: H256) -> Box<dyn Future<Item = Option<URLHintResult>, Error = String> + Send> {
let client = self.client.clone(); let client = self.client.clone();
let future = self.registrar.get_address(GITHUB_HINT) let future = self.registrar.get_address(GITHUB_HINT)

View File

@ -21,6 +21,7 @@
extern crate client_traits; extern crate client_traits;
extern crate common_types; extern crate common_types;
extern crate ethabi; extern crate ethabi;
extern crate ethabi_derive;
extern crate ethcore; extern crate ethcore;
extern crate ethcore_sync as sync; extern crate ethcore_sync as sync;
extern crate ethereum_types; extern crate ethereum_types;
@ -37,8 +38,6 @@ extern crate target_info;
#[macro_use] #[macro_use]
extern crate ethabi_contract; extern crate ethabi_contract;
#[macro_use] #[macro_use]
extern crate ethabi_derive;
#[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate log; extern crate log;

View File

@ -144,11 +144,11 @@ pub struct Updater<O = OperationsContractClient, F = fetch::Client, T = StdTimeP
// Useful environmental stuff. // Useful environmental stuff.
update_policy: UpdatePolicy, update_policy: UpdatePolicy,
weak_self: Mutex<Weak<Updater<O, F, T, R>>>, weak_self: Mutex<Weak<Updater<O, F, T, R>>>,
client: Weak<BlockChainClient>, client: Weak<dyn BlockChainClient>,
sync: Option<Weak<SyncProvider>>, sync: Option<Weak<dyn SyncProvider>>,
fetcher: F, fetcher: F,
operations_client: O, operations_client: O,
exit_handler: Mutex<Option<Box<Fn() + 'static + Send>>>, exit_handler: Mutex<Option<Box<dyn Fn() + 'static + Send>>>,
time_provider: T, time_provider: T,
rng: R, rng: R,
@ -205,11 +205,11 @@ pub trait OperationsClient: Send + Sync + 'static {
/// `OperationsClient` that delegates calls to the operations contract. /// `OperationsClient` that delegates calls to the operations contract.
pub struct OperationsContractClient { pub struct OperationsContractClient {
client: Weak<BlockChainClient>, client: Weak<dyn BlockChainClient>,
} }
impl OperationsContractClient { impl OperationsContractClient {
fn new(client: Weak<BlockChainClient>) -> Self { fn new(client: Weak<dyn BlockChainClient>) -> Self {
OperationsContractClient { OperationsContractClient {
client client
} }
@ -368,8 +368,8 @@ impl GenRange for ThreadRngGenRange {
impl Updater { impl Updater {
/// `Updater` constructor /// `Updater` constructor
pub fn new( pub fn new(
client: &Weak<BlockChainClient>, client: &Weak<dyn BlockChainClient>,
sync: &Weak<SyncProvider>, sync: &Weak<dyn SyncProvider>,
update_policy: UpdatePolicy, update_policy: UpdatePolicy,
fetcher: fetch::Client, fetcher: fetch::Client,
) -> Arc<Updater> { ) -> Arc<Updater> {
@ -756,7 +756,7 @@ pub mod tests {
#[derive(Clone)] #[derive(Clone)]
struct FakeFetch { struct FakeFetch {
on_done: Arc<Mutex<Option<Box<Fn(Result<PathBuf, Error>) + Send>>>>, on_done: Arc<Mutex<Option<Box<dyn Fn(Result<PathBuf, Error>) + Send>>>>,
} }
impl FakeFetch { impl FakeFetch {
@ -772,7 +772,7 @@ pub mod tests {
} }
impl HashFetch for FakeFetch { impl HashFetch for FakeFetch {
fn fetch(&self, _hash: H256, _abort: fetch::Abort, on_done: Box<Fn(Result<PathBuf, Error>) + Send>) { fn fetch(&self, _hash: H256, _abort: fetch::Abort, on_done: Box<dyn Fn(Result<PathBuf, Error>) + Send>) {
*self.on_done.lock() = Some(on_done); *self.on_done.lock() = Some(on_done);
} }
} }

View File

@ -67,7 +67,7 @@ pub(crate) fn serde_error(expected: &str, field: Option<&str>) -> ErrorKind {
} }
impl Fail for Error { impl Fail for Error {
fn cause(&self) -> Option<&Fail> { fn cause(&self) -> Option<&dyn Fail> {
self.inner.cause() self.inner.cause()
} }

View File

@ -271,7 +271,7 @@ impl Client {
} }
impl Fetch for Client { impl Fetch for Client {
type Result = Box<Future<Item=Response, Error=Error> + Send + 'static>; type Result = Box<dyn Future<Item=Response, Error=Error> + Send + 'static>;
fn fetch(&self, request: Request, abort: Abort) -> Self::Result { fn fetch(&self, request: Request, abort: Abort) -> Self::Result {
debug!(target: "fetch", "fetching: {:?}", request.url()); debug!(target: "fetch", "fetching: {:?}", request.url());
@ -608,7 +608,7 @@ impl fmt::Display for Error {
impl ::std::error::Error for Error { impl ::std::error::Error for Error {
fn description(&self) -> &str { "Fetch client error" } fn description(&self) -> &str { "Fetch client error" }
fn cause(&self) -> Option<&::std::error::Error> { None } fn cause(&self) -> Option<&dyn std::error::Error> { None }
} }
impl From<hyper::Error> for Error { impl From<hyper::Error> for Error {

View File

@ -32,7 +32,7 @@ use std::{fs, io, error};
use kvdb::DBTransaction; use kvdb::DBTransaction;
use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig}; use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig};
fn other_io_err<E>(e: E) -> io::Error where E: Into<Box<error::Error + Send + Sync>> { fn other_io_err<E>(e: E) -> io::Error where E: Into<Box<dyn error::Error + Send + Sync>> {
io::Error::new(io::ErrorKind::Other, e) io::Error::new(io::ErrorKind::Other, e)
} }
@ -209,7 +209,7 @@ impl TempIndex {
/// Manages database migration. /// Manages database migration.
pub struct Manager { pub struct Manager {
config: Config, config: Config,
migrations: Vec<Box<Migration>>, migrations: Vec<Box<dyn Migration>>,
} }
impl Manager { impl Manager {
@ -317,7 +317,7 @@ impl Manager {
} }
/// Find all needed migrations. /// Find all needed migrations.
fn migrations_from(&mut self, version: u32) -> Vec<&mut Box<Migration>> { fn migrations_from(&mut self, version: u32) -> Vec<&mut Box<dyn Migration>> {
self.migrations.iter_mut().filter(|m| m.version() > version).collect() self.migrations.iter_mut().filter(|m| m.version() > version).collect()
} }
} }

View File

@ -97,12 +97,12 @@ impl SocketAddrExt for Ipv4Addr {
self.is_multicast() || self.is_multicast() ||
self.is_shared_space() || self.is_shared_space() ||
self.is_special_purpose() || self.is_special_purpose() ||
self.is_benchmarking() || SocketAddrExt::is_benchmarking(self) ||
self.is_future_use() self.is_future_use()
} }
fn is_usable_public(&self) -> bool { fn is_usable_public(&self) -> bool {
!self.is_reserved() && !SocketAddrExt::is_reserved(self) &&
!self.is_private() !self.is_private()
} }
@ -186,7 +186,7 @@ impl SocketAddrExt for IpAddr {
fn is_reserved(&self) -> bool { fn is_reserved(&self) -> bool {
match *self { match *self {
IpAddr::V4(ref ip) => ip.is_reserved(), IpAddr::V4(ref ip) => SocketAddrExt::is_reserved(ip),
IpAddr::V6(ref ip) => ip.is_reserved(), IpAddr::V6(ref ip) => ip.is_reserved(),
} }
} }
@ -290,7 +290,7 @@ pub fn select_public_address(port: u16) -> SocketAddr {
//prefer IPV4 bindings //prefer IPV4 bindings
for addr in &list { //TODO: use better criteria than just the first in the list for addr in &list { //TODO: use better criteria than just the first in the list
match addr { match addr {
IpAddr::V4(a) if !a.is_reserved() => { IpAddr::V4(a) if !SocketAddrExt::is_reserved(a) => {
return SocketAddr::V4(SocketAddrV4::new(*a, port)); return SocketAddr::V4(SocketAddrV4::new(*a, port));
}, },
_ => {}, _ => {},

View File

@ -145,7 +145,7 @@ impl From<Option<io::Error>> for AddressResolveError {
} }
impl error::Error for Error { impl error::Error for Error {
fn source(&self) -> Option<&(error::Error + 'static)> { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self { match self {
Error::Decompression(e) => Some(e), Error::Decompression(e) => Some(e),
Error::Rlp(e) => Some(e), Error::Rlp(e) => Some(e),

View File

@ -75,7 +75,7 @@ pub enum NetworkIoMessage {
/// Register a new protocol handler. /// Register a new protocol handler.
AddHandler { AddHandler {
/// Handler shared instance. /// Handler shared instance.
handler: Arc<NetworkProtocolHandler + Sync>, handler: Arc<dyn NetworkProtocolHandler + Sync>,
/// Protocol Id. /// Protocol Id.
protocol: ProtocolId, protocol: ProtocolId,
/// Supported protocol versions and number of packet IDs reserved by the protocol (packet count). /// Supported protocol versions and number of packet IDs reserved by the protocol (packet count).
@ -361,15 +361,15 @@ impl<'a, T> NetworkContext for &'a T where T: ?Sized + NetworkContext {
/// `Message` is the type for message data. /// `Message` is the type for message data.
pub trait NetworkProtocolHandler: Sync + Send { pub trait NetworkProtocolHandler: Sync + Send {
/// Initialize the handler /// Initialize the handler
fn initialize(&self, _io: &NetworkContext) {} fn initialize(&self, _io: &dyn NetworkContext) {}
/// Called when new network packet received. /// Called when new network packet received.
fn read(&self, io: &NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]); fn read(&self, io: &dyn NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]);
/// Called when new peer is connected. Only called when peer supports the same protocol. /// Called when new peer is connected. Only called when peer supports the same protocol.
fn connected(&self, io: &NetworkContext, peer: &PeerId); fn connected(&self, io: &dyn NetworkContext, peer: &PeerId);
/// Called when a previously connected peer disconnects. /// Called when a previously connected peer disconnects.
fn disconnected(&self, io: &NetworkContext, peer: &PeerId); fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId);
/// Timer function called after a timeout created with `NetworkContext::timeout`. /// Timer function called after a timeout created with `NetworkContext::timeout`.
fn timeout(&self, _io: &NetworkContext, _timer: TimerToken) {} fn timeout(&self, _io: &dyn NetworkContext, _timer: TimerToken) {}
} }
/// Non-reserved peer modes. /// Non-reserved peer modes.

View File

@ -16,10 +16,9 @@
extern crate futures; extern crate futures;
extern crate ethabi; extern crate ethabi;
extern crate ethabi_derive;
extern crate keccak_hash; extern crate keccak_hash;
#[macro_use]
extern crate ethabi_derive;
#[macro_use] #[macro_use]
extern crate ethabi_contract; extern crate ethabi_contract;

View File

@ -24,25 +24,25 @@ use_contract!(registrar, "res/registrar.json");
// Maps a domain name to an Ethereum address // Maps a domain name to an Ethereum address
const DNS_A_RECORD: &'static str = "A"; const DNS_A_RECORD: &'static str = "A";
pub type Asynchronous = Box<Future<Item=Bytes, Error=String> + Send>; pub type Asynchronous = Box<dyn Future<Item=Bytes, Error=String> + Send>;
pub type Synchronous = Result<Bytes, String>; pub type Synchronous = Result<Bytes, String>;
/// Registrar is dedicated interface to access the registrar contract /// Registrar is dedicated interface to access the registrar contract
/// which in turn generates an address when a client requests one /// which in turn generates an address when a client requests one
pub struct Registrar { pub struct Registrar {
client: Arc<RegistrarClient<Call=Asynchronous>>, client: Arc<dyn RegistrarClient<Call=Asynchronous>>,
} }
impl Registrar { impl Registrar {
/// Registrar constructor /// Registrar constructor
pub fn new(client: Arc<RegistrarClient<Call=Asynchronous>>) -> Self { pub fn new(client: Arc<dyn RegistrarClient<Call=Asynchronous>>) -> Self {
Self { Self {
client: client, client: client,
} }
} }
/// Generate an address for the given key /// Generate an address for the given key
pub fn get_address<'a>(&self, key: &'a str) -> Box<Future<Item = Address, Error = String> + Send> { pub fn get_address<'a>(&self, key: &'a str) -> Box<dyn Future<Item = Address, Error = String> + Send> {
// Address of the registrar itself // Address of the registrar itself
let registrar_address = match self.client.registrar_address() { let registrar_address = match self.client.registrar_address() {
Ok(a) => a, Ok(a) => a,

View File

@ -40,7 +40,7 @@ pub trait Decompressor {
} }
/// Call this function to compress rlp. /// Call this function to compress rlp.
pub fn compress(c: &[u8], swapper: &Compressor) -> ElasticArray1024<u8> { pub fn compress(c: &[u8], swapper: &dyn Compressor) -> ElasticArray1024<u8> {
let rlp = Rlp::new(c); let rlp = Rlp::new(c);
if rlp.is_data() { if rlp.is_data() {
ElasticArray1024::from_slice(swapper.compressed(rlp.as_raw()).unwrap_or_else(|| rlp.as_raw())) ElasticArray1024::from_slice(swapper.compressed(rlp.as_raw()).unwrap_or_else(|| rlp.as_raw()))
@ -50,7 +50,7 @@ pub fn compress(c: &[u8], swapper: &Compressor) -> ElasticArray1024<u8> {
} }
/// Call this function to decompress rlp. /// Call this function to decompress rlp.
pub fn decompress(c: &[u8], swapper: &Decompressor) -> ElasticArray1024<u8> { pub fn decompress(c: &[u8], swapper: &dyn Decompressor) -> ElasticArray1024<u8> {
let rlp = Rlp::new(c); let rlp = Rlp::new(c);
if rlp.is_data() { if rlp.is_data() {
ElasticArray1024::from_slice(swapper.decompressed(rlp.as_raw()).unwrap_or_else(|| rlp.as_raw())) ElasticArray1024::from_slice(swapper.decompressed(rlp.as_raw()).unwrap_or_else(|| rlp.as_raw()))