Fix warnings: dyn
This commit is contained in:
@@ -63,13 +63,13 @@ mod accounts {
|
||||
pub fn private_tx_signer(
|
||||
_account_provider: Arc<AccountProvider>,
|
||||
_passwords: &[Password],
|
||||
) -> Result<Arc<::ethcore_private_tx::Signer>, String> {
|
||||
) -> Result<Arc<dyn ethcore_private_tx::Signer>, String> {
|
||||
Ok(Arc::new(::ethcore_private_tx::DummySigner))
|
||||
}
|
||||
|
||||
pub fn accounts_list(
|
||||
_account_provider: Arc<AccountProvider>,
|
||||
) -> Arc<Fn() -> Vec<Address> + Send + Sync> {
|
||||
) -> Arc<dyn Fn() -> Vec<Address> + Send + Sync> {
|
||||
Arc::new(|| vec![])
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,7 @@ mod accounts {
|
||||
pub fn private_tx_signer(
|
||||
accounts: Arc<AccountProvider>,
|
||||
passwords: &[Password],
|
||||
) -> Result<Arc<::ethcore_private_tx::Signer>, String> {
|
||||
) -> Result<Arc<dyn crate::ethcore_private_tx::Signer>, String> {
|
||||
Ok(Arc::new(self::private_tx::AccountSigner {
|
||||
accounts,
|
||||
passwords: passwords.to_vec(),
|
||||
@@ -278,7 +278,7 @@ mod accounts {
|
||||
|
||||
pub fn accounts_list(
|
||||
account_provider: Arc<AccountProvider>,
|
||||
) -> Arc<Fn() -> Vec<Address> + Send + Sync> {
|
||||
) -> Arc<dyn Fn() -> Vec<Address> + Send + Sync> {
|
||||
Arc::new(move || account_provider.accounts().unwrap_or_default())
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ mod migration;
|
||||
pub use self::migration::migrate;
|
||||
|
||||
struct AppDB {
|
||||
key_value: Arc<KeyValueDB>,
|
||||
key_value: Arc<dyn KeyValueDB>,
|
||||
blooms: blooms_db::Database,
|
||||
trace_blooms: blooms_db::Database,
|
||||
}
|
||||
|
||||
impl BlockChainDB for AppDB {
|
||||
fn key_value(&self) -> &Arc<KeyValueDB> {
|
||||
fn key_value(&self) -> &Arc<dyn KeyValueDB> {
|
||||
&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.
|
||||
#[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;
|
||||
|
||||
let mut db_path = PathBuf::from(data_path);
|
||||
@@ -75,7 +75,7 @@ pub fn open_secretstore_db(data_path: &str) -> Result<Arc<KeyValueDB>, String> {
|
||||
pub fn restoration_db_handler(
|
||||
client_path: &Path,
|
||||
client_config: &ClientConfig,
|
||||
) -> Box<BlockChainDBHandler> {
|
||||
) -> Box<dyn BlockChainDBHandler> {
|
||||
let client_db_config = helpers::client_db_config(client_path, client_config);
|
||||
|
||||
struct RestorationDBHandler {
|
||||
@@ -83,7 +83,7 @@ pub fn restoration_db_handler(
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ pub fn open_db(
|
||||
client_path: &str,
|
||||
cache_config: &CacheConfig,
|
||||
compaction: &DatabaseCompactionProfile,
|
||||
) -> io::Result<Arc<BlockChainDB>> {
|
||||
) -> io::Result<Arc<dyn BlockChainDB>> {
|
||||
let path = Path::new(client_path);
|
||||
|
||||
let db_config = DatabaseConfig {
|
||||
@@ -110,7 +110,10 @@ pub fn open_db(
|
||||
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 blooms_path = path.join("blooms");
|
||||
|
||||
@@ -127,8 +127,8 @@ pub trait InformantData: Send + Sync {
|
||||
/// Informant data for a full node.
|
||||
pub struct FullNodeInformantData {
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Option<Arc<SyncProvider>>,
|
||||
pub net: Option<Arc<ManageNetwork>>,
|
||||
pub sync: Option<Arc<dyn SyncProvider>>,
|
||||
pub net: Option<Arc<dyn ManageNetwork>>,
|
||||
}
|
||||
|
||||
impl InformantData for FullNodeInformantData {
|
||||
@@ -191,7 +191,7 @@ impl InformantData for FullNodeInformantData {
|
||||
|
||||
/// Informant data for a light node -- note that the network is required.
|
||||
pub struct LightNodeInformantData {
|
||||
pub client: Arc<LightChainClient>,
|
||||
pub client: Arc<dyn LightChainClient>,
|
||||
pub sync: Arc<LightSync>,
|
||||
pub cache: Arc<Mutex<LightDataCache>>,
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ impl Default for Configuration {
|
||||
|
||||
pub fn start_server(
|
||||
conf: Configuration,
|
||||
client: Arc<BlockChainClient>,
|
||||
client: Arc<dyn BlockChainClient>,
|
||||
) -> Result<Option<Listening>, ServerError> {
|
||||
if !conf.enabled {
|
||||
return Ok(None);
|
||||
|
||||
@@ -35,7 +35,7 @@ use parking_lot::RwLock;
|
||||
|
||||
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.
|
||||
pub struct EpochFetch {
|
||||
@@ -88,8 +88,8 @@ impl ChainDataFetcher for EpochFetch {
|
||||
fn epoch_transition(
|
||||
&self,
|
||||
hash: H256,
|
||||
engine: Arc<EthEngine>,
|
||||
checker: Arc<StateDependentProof<EthereumMachine>>,
|
||||
engine: Arc<dyn EthEngine>,
|
||||
checker: Arc<dyn StateDependentProof<EthereumMachine>>,
|
||||
) -> Self::Transition {
|
||||
self.request(request::Signal {
|
||||
hash: hash,
|
||||
|
||||
@@ -25,22 +25,22 @@ use ethcore_logger::Config as LogConfig;
|
||||
pub use sync::{EthSync, ManageNetwork, PrivateTxHandler, SyncProvider};
|
||||
|
||||
pub type SyncModules = (
|
||||
Arc<SyncProvider>,
|
||||
Arc<ManageNetwork>,
|
||||
Arc<ChainNotify>,
|
||||
Arc<dyn SyncProvider>,
|
||||
Arc<dyn ManageNetwork>,
|
||||
Arc<dyn ChainNotify>,
|
||||
mpsc::Sender<sync::PriorityTask>,
|
||||
);
|
||||
|
||||
pub fn sync(
|
||||
config: SyncConfig,
|
||||
network_config: NetworkConfiguration,
|
||||
chain: Arc<BlockChainClient>,
|
||||
snapshot_service: Arc<SnapshotService>,
|
||||
private_tx_handler: Option<Arc<PrivateTxHandler>>,
|
||||
provider: Arc<Provider>,
|
||||
chain: Arc<dyn BlockChainClient>,
|
||||
snapshot_service: Arc<dyn SnapshotService>,
|
||||
private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
|
||||
provider: Arc<dyn Provider>,
|
||||
_log_settings: &LogConfig,
|
||||
attached_protos: Vec<AttachedProtocol>,
|
||||
connection_filter: Option<Arc<ConnectionFilter>>,
|
||||
connection_filter: Option<Arc<dyn ConnectionFilter>>,
|
||||
) -> Result<SyncModules, sync::Error> {
|
||||
let eth_sync = EthSync::new(
|
||||
Params {
|
||||
@@ -56,9 +56,9 @@ pub fn sync(
|
||||
)?;
|
||||
|
||||
Ok((
|
||||
eth_sync.clone() as Arc<SyncProvider>,
|
||||
eth_sync.clone() as Arc<ManageNetwork>,
|
||||
eth_sync.clone() as Arc<ChainNotify>,
|
||||
eth_sync.clone() as Arc<dyn SyncProvider>,
|
||||
eth_sync.clone() as Arc<dyn ManageNetwork>,
|
||||
eth_sync.clone() as Arc<dyn ChainNotify>,
|
||||
eth_sync.priority_tasks(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -235,16 +235,16 @@ pub trait Dependencies {
|
||||
pub struct FullDependencies {
|
||||
pub signer_service: Arc<SignerService>,
|
||||
pub client: Arc<Client>,
|
||||
pub snapshot: Arc<SnapshotService>,
|
||||
pub sync: Arc<SyncProvider>,
|
||||
pub net: Arc<ManageNetwork>,
|
||||
pub snapshot: Arc<dyn SnapshotService>,
|
||||
pub sync: Arc<dyn SyncProvider>,
|
||||
pub net: Arc<dyn ManageNetwork>,
|
||||
pub accounts: Arc<AccountProvider>,
|
||||
pub private_tx_service: Option<Arc<PrivateTxService>>,
|
||||
pub miner: Arc<Miner>,
|
||||
pub external_miner: Arc<ExternalMiner>,
|
||||
pub logger: Arc<RotatingLogger>,
|
||||
pub settings: Arc<NetworkSettings>,
|
||||
pub net_service: Arc<ManageNetwork>,
|
||||
pub net_service: Arc<dyn ManageNetwork>,
|
||||
pub updater: Arc<Updater>,
|
||||
pub geth_compatibility: bool,
|
||||
pub experimental_rpcs: bool,
|
||||
@@ -502,7 +502,7 @@ pub struct LightDependencies<T> {
|
||||
pub signer_service: Arc<SignerService>,
|
||||
pub client: Arc<T>,
|
||||
pub sync: Arc<LightSync>,
|
||||
pub net: Arc<ManageNetwork>,
|
||||
pub net: Arc<dyn ManageNetwork>,
|
||||
pub accounts: Arc<AccountProvider>,
|
||||
pub logger: Arc<RotatingLogger>,
|
||||
pub settings: Arc<NetworkSettings>,
|
||||
|
||||
@@ -691,7 +691,7 @@ where
|
||||
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>,
|
||||
Arc::downgrade(&client) as Weak<dyn BlockChainClient>,
|
||||
a,
|
||||
))
|
||||
});
|
||||
@@ -762,8 +762,8 @@ where
|
||||
None
|
||||
};
|
||||
|
||||
let private_tx_sync: Option<Arc<PrivateTxHandler>> = match cmd.private_tx_enabled {
|
||||
true => Some(private_tx_service.clone() as Arc<PrivateTxHandler>),
|
||||
let private_tx_sync: Option<Arc<dyn PrivateTxHandler>> = match cmd.private_tx_enabled {
|
||||
true => Some(private_tx_service.clone() as Arc<dyn PrivateTxHandler>),
|
||||
false => None,
|
||||
};
|
||||
|
||||
@@ -779,7 +779,7 @@ where
|
||||
attached_protos,
|
||||
connection_filter
|
||||
.clone()
|
||||
.map(|f| f as Arc<::sync::ConnectionFilter + 'static>),
|
||||
.map(|f| f as Arc<dyn crate::sync::ConnectionFilter + 'static>),
|
||||
)
|
||||
.map_err(|e| format!("Sync error: {}", e))?;
|
||||
|
||||
@@ -840,7 +840,7 @@ where
|
||||
// the updater service
|
||||
let updater_fetch = fetch.clone();
|
||||
let updater = Updater::new(
|
||||
&Arc::downgrade(&(service.client() as Arc<BlockChainClient>)),
|
||||
&Arc::downgrade(&(service.client() as Arc<dyn BlockChainClient>)),
|
||||
&Arc::downgrade(&sync_provider),
|
||||
update_policy,
|
||||
hash_fetch::Client::with_fetch(contract_client.clone(), updater_fetch, runtime.executor()),
|
||||
@@ -1002,7 +1002,7 @@ enum RunningClientInner {
|
||||
>,
|
||||
informant: Arc<Informant<LightNodeInformantData>>,
|
||||
client: Arc<LightClient>,
|
||||
keep_alive: Box<Any>,
|
||||
keep_alive: Box<dyn Any>,
|
||||
},
|
||||
Full {
|
||||
rpc:
|
||||
@@ -1010,7 +1010,7 @@ enum RunningClientInner {
|
||||
informant: Arc<Informant<FullNodeInformantData>>,
|
||||
client: Arc<Client>,
|
||||
client_service: Arc<ClientService>,
|
||||
keep_alive: Box<Any>,
|
||||
keep_alive: Box<dyn Any>,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ pub struct Dependencies<'a> {
|
||||
/// Blockchain client.
|
||||
pub client: Arc<Client>,
|
||||
/// Sync provider.
|
||||
pub sync: Arc<SyncProvider>,
|
||||
pub sync: Arc<dyn SyncProvider>,
|
||||
/// Miner service.
|
||||
pub miner: Arc<Miner>,
|
||||
/// Account provider.
|
||||
@@ -138,7 +138,7 @@ mod server {
|
||||
|
||||
/// Key server
|
||||
pub struct KeyServer {
|
||||
_key_server: Box<ethcore_secretstore::KeyServer>,
|
||||
_key_server: Box<dyn ethcore_secretstore::KeyServer>,
|
||||
}
|
||||
|
||||
impl KeyServer {
|
||||
@@ -148,57 +148,58 @@ mod server {
|
||||
deps: Dependencies,
|
||||
executor: Executor,
|
||||
) -> Result<Self, String> {
|
||||
let self_secret: Arc<ethcore_secretstore::NodeKeyPair> = match conf.self_secret.take() {
|
||||
Some(NodeSecretKey::Plain(secret)) => {
|
||||
Arc::new(ethcore_secretstore::PlainNodeKeyPair::new(
|
||||
KeyPair::from_secret(secret)
|
||||
.map_err(|e| format!("invalid secret: {}", e))?,
|
||||
))
|
||||
}
|
||||
#[cfg(feature = "accounts")]
|
||||
Some(NodeSecretKey::KeyStore(account)) => {
|
||||
// Check if account exists
|
||||
if !deps.account_provider.has_account(account.clone()) {
|
||||
return Err(format!(
|
||||
"Account {} passed as secret store node key is not found",
|
||||
account
|
||||
));
|
||||
let self_secret: Arc<dyn ethcore_secretstore::NodeKeyPair> =
|
||||
match conf.self_secret.take() {
|
||||
Some(NodeSecretKey::Plain(secret)) => {
|
||||
Arc::new(ethcore_secretstore::PlainNodeKeyPair::new(
|
||||
KeyPair::from_secret(secret)
|
||||
.map_err(|e| format!("invalid secret: {}", e))?,
|
||||
))
|
||||
}
|
||||
|
||||
// Check if any passwords have been read from the password file(s)
|
||||
if deps.accounts_passwords.is_empty() {
|
||||
return Err(format!(
|
||||
"No password found for the secret store node account {}",
|
||||
account
|
||||
));
|
||||
}
|
||||
|
||||
// Attempt to sign in the engine signer.
|
||||
let password = deps
|
||||
.accounts_passwords
|
||||
.iter()
|
||||
.find(|p| {
|
||||
deps.account_provider
|
||||
.sign(account.clone(), Some((*p).clone()), Default::default())
|
||||
.is_ok()
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
format!(
|
||||
"No valid password for the secret store node account {}",
|
||||
#[cfg(feature = "accounts")]
|
||||
Some(NodeSecretKey::KeyStore(account)) => {
|
||||
// Check if account exists
|
||||
if !deps.account_provider.has_account(account.clone()) {
|
||||
return Err(format!(
|
||||
"Account {} passed as secret store node key is not found",
|
||||
account
|
||||
));
|
||||
}
|
||||
|
||||
// Check if any passwords have been read from the password file(s)
|
||||
if deps.accounts_passwords.is_empty() {
|
||||
return Err(format!(
|
||||
"No password found for the secret store node account {}",
|
||||
account
|
||||
));
|
||||
}
|
||||
|
||||
// Attempt to sign in the engine signer.
|
||||
let password = deps
|
||||
.accounts_passwords
|
||||
.iter()
|
||||
.find(|p| {
|
||||
deps.account_provider
|
||||
.sign(account.clone(), Some((*p).clone()), Default::default())
|
||||
.is_ok()
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
format!(
|
||||
"No valid password for the secret store node account {}",
|
||||
account
|
||||
)
|
||||
})?;
|
||||
Arc::new(
|
||||
ethcore_secretstore::KeyStoreNodeKeyPair::new(
|
||||
deps.account_provider,
|
||||
account,
|
||||
password.clone(),
|
||||
)
|
||||
})?;
|
||||
Arc::new(
|
||||
ethcore_secretstore::KeyStoreNodeKeyPair::new(
|
||||
deps.account_provider,
|
||||
account,
|
||||
password.clone(),
|
||||
.map_err(|e| format!("{}", e))?,
|
||||
)
|
||||
.map_err(|e| format!("{}", e))?,
|
||||
)
|
||||
}
|
||||
None => return Err("self secret is required when using secretstore".into()),
|
||||
};
|
||||
}
|
||||
None => return Err("self secret is required when using secretstore".into()),
|
||||
};
|
||||
|
||||
info!(
|
||||
"Starting SecretStore node: {}",
|
||||
|
||||
@@ -45,7 +45,7 @@ pub struct NetPoolHandle {
|
||||
/// Pool handle.
|
||||
handle: Arc<WhisperNetwork<Arc<FilterManager>>>,
|
||||
/// Network manager.
|
||||
net: Arc<ManageNetwork>,
|
||||
net: Arc<dyn ManageNetwork>,
|
||||
}
|
||||
|
||||
impl PoolHandle for NetPoolHandle {
|
||||
@@ -73,7 +73,10 @@ pub struct RpcFactory {
|
||||
}
|
||||
|
||||
impl RpcFactory {
|
||||
pub fn make_handler(&self, net: Arc<ManageNetwork>) -> WhisperClient<NetPoolHandle, Metadata> {
|
||||
pub fn make_handler(
|
||||
&self,
|
||||
net: Arc<dyn ManageNetwork>,
|
||||
) -> WhisperClient<NetPoolHandle, Metadata> {
|
||||
let handle = NetPoolHandle {
|
||||
handle: self.net.clone(),
|
||||
net: net,
|
||||
|
||||
Reference in New Issue
Block a user