Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into dp/chore/sort-out-ClientIoMessage
Browse files Browse the repository at this point in the history
* master:
  fix compile warnings (#10993)
  • Loading branch information
dvdplm committed Aug 27, 2019
2 parents 4e8ab46 + dab2a6b commit 22df32b
Show file tree
Hide file tree
Showing 69 changed files with 205 additions and 201 deletions.
6 changes: 3 additions & 3 deletions accounts/ethstore/src/accounts_dir/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl<T> KeyDirectory for DiskDirectory<T> where T: KeyFileManager {

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)
}

Expand All @@ -294,12 +294,12 @@ impl<T> KeyDirectory 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)?;
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)?;
Ok(Box::new(vault_dir))
}
Expand Down
8 changes: 4 additions & 4 deletions accounts/ethstore/src/accounts_dir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ pub trait KeyDirectory: Send + Sync {
/// Get directory filesystem path, if available
fn path(&self) -> Option<&PathBuf> { None }
/// 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
fn unique_repr(&self) -> Result<u64, Error>;
}

/// Vaults provider
pub trait VaultKeyDirectoryProvider {
/// 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
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
fn list_vaults(&self) -> Result<Vec<String>, Error>;
/// Get vault meta
Expand All @@ -77,7 +77,7 @@ pub trait VaultKeyDirectoryProvider {
/// Vault directory
pub trait VaultKeyDirectory: KeyDirectory {
/// Cast to `KeyDirectory`
fn as_key_directory(&self) -> &KeyDirectory;
fn as_key_directory(&self) -> &dyn KeyDirectory;
/// Vault name
fn name(&self) -> &str;
/// Get vault key
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethstore/src/accounts_dir/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl VaultDiskDirectory {
}

impl VaultKeyDirectory for VaultDiskDirectory {
fn as_key_directory(&self) -> &KeyDirectory {
fn as_key_directory(&self) -> &dyn KeyDirectory {
self
}

Expand Down
14 changes: 7 additions & 7 deletions accounts/ethstore/src/ethstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ pub struct EthStore {

impl EthStore {
/// 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)
}

/// 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 {
store: EthMultiStore::open_with_iterations(directory, iterations)?,
})
Expand Down Expand Up @@ -184,7 +184,7 @@ impl SecretStore for EthStore {
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 secret = account.crypto.secret(password)?;
new_store.insert_account(new_vault, secret, new_password)?;
Expand Down Expand Up @@ -256,11 +256,11 @@ impl SecretStore for EthStore {

/// Similar to `EthStore` but may store many accounts (with different passwords) for the same `Address`
pub struct EthMultiStore {
dir: Box<KeyDirectory>,
dir: Box<dyn KeyDirectory>,
iterations: u32,
// order lock: cache, then vaults
cache: RwLock<BTreeMap<StoreAccountRef, Vec<SafeAccount>>>,
vaults: Mutex<HashMap<String, Box<VaultKeyDirectory>>>,
vaults: Mutex<HashMap<String, Box<dyn VaultKeyDirectory>>>,
timestamp: Mutex<Timestamp>,
}

Expand All @@ -272,12 +272,12 @@ struct Timestamp {

impl EthMultiStore {
/// 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)
}

/// 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 {
dir: directory,
vaults: Mutex::new(HashMap::new()),
Expand Down
6 changes: 3 additions & 3 deletions accounts/ethstore/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use dir;
use Error;

/// 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 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());
Expand All @@ -40,7 +40,7 @@ pub fn import_account(path: &Path, dst: &KeyDirectory) -> Result<Address, Error>
}

/// 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 existing_accounts = dst.load()?.into_iter()
.map(|a| a.address)
Expand All @@ -64,7 +64,7 @@ pub fn read_geth_accounts(testnet: bool) -> Vec<Address> {
}

/// 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 accounts = src.load()?;
let existing_accounts = dst.load()?.into_iter().map(|a| a.address).collect::<HashSet<_>>();
Expand Down
2 changes: 1 addition & 1 deletion accounts/ethstore/src/secret_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub trait SecretStore: SimpleSecretStore {
/// Imports existing JSON wallet
fn import_wallet(&self, vault: SecretVaultRef, json: &[u8], password: &Password, gen_id: bool) -> Result<StoreAccountRef, Error>;
/// 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.
fn test_password(&self, account: &StoreAccountRef, password: &Password) -> Result<bool, Error>;

Expand Down
4 changes: 2 additions & 2 deletions accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct AccountProvider {
/// Address book.
address_book: RwLock<AddressBook>,
/// Accounts on disk
sstore: Box<SecretStore>,
sstore: Box<dyn SecretStore>,
/// Accounts unlocked with rolling tokens
transient_sstore: EthMultiStore,
/// When unlocking account permanently we additionally keep a raw secret in memory
Expand All @@ -80,7 +80,7 @@ fn transient_sstore() -> EthMultiStore {

impl AccountProvider {
/// 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() {
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",
Expand Down
2 changes: 1 addition & 1 deletion cli-signer/rpc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern crate log;
extern crate matches;

/// 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)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/private-tx/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub enum Error {
}

impl error::Error for Error {
fn source(&self) -> Option<&(error::Error + 'static)> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Error::Io(e) => Some(e),
Error::Decoder(e) => Some(e),
Expand Down
25 changes: 12 additions & 13 deletions ethcore/private-tx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ extern crate transaction_pool as txpool;
extern crate url;
#[macro_use]
extern crate log as ethlog;
#[macro_use]
extern crate ethabi_derive;
#[macro_use]
extern crate ethabi_contract;
Expand Down Expand Up @@ -206,17 +205,17 @@ impl Signer for KeyPairSigner {

/// Manager of private transactions
pub struct Provider {
encryptor: Box<Encryptor>,
encryptor: Box<dyn Encryptor>,
validator_accounts: HashSet<Address>,
signer_account: Option<Address>,
notify: RwLock<Vec<Weak<ChainNotify>>>,
notify: RwLock<Vec<Weak<dyn ChainNotify>>>,
transactions_for_signing: RwLock<SigningStore>,
transactions_for_verification: VerificationStore,
client: Arc<Client>,
miner: Arc<Miner>,
accounts: Arc<Signer>,
channel: IoChannel<ClientIoMessage<Client>>,
keys_provider: Arc<KeyProvider>,
accounts: Arc<dyn Signer>,
channel: IoChannel<ClientIoMessage>,
keys_provider: Arc<dyn KeyProvider>,
logging: Option<Logging>,
use_offchain_storage: bool,
state_storage: PrivateStateStorage,
Expand All @@ -235,12 +234,12 @@ impl Provider {
pub fn new(
client: Arc<Client>,
miner: Arc<Miner>,
accounts: Arc<Signer>,
encryptor: Box<Encryptor>,
accounts: Arc<dyn Signer>,
encryptor: Box<dyn Encryptor>,
config: ProviderConfig,
channel: IoChannel<ClientIoMessage<Client>>,
keys_provider: Arc<KeyProvider>,
db: Arc<KeyValueDB>,
channel: IoChannel<ClientIoMessage>,
keys_provider: Arc<dyn KeyProvider>,
db: Arc<dyn KeyValueDB>,
) -> Self {
keys_provider.update_acl_contract();
Provider {
Expand Down Expand Up @@ -269,11 +268,11 @@ impl Provider {
// TODO [ToDr] Don't use `ChainNotify` here!
// Better to create a separate notification type for this.
/// 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));
}

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() {
if let Some(n) = np.upgrade() {
f(&*n);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/private-tx/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ impl LogsSerializer for FileLogsSerializer {
/// Private transactions logging
pub struct Logging {
logs: RwLock<HashMap<H256, TransactionLog>>,
logs_serializer: Arc<LogsSerializer>,
logs_serializer: Arc<dyn LogsSerializer>,
mono_time: MonoTime,
}

impl Logging {
/// 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 {
logs: RwLock::new(HashMap::new()),
logs_serializer,
Expand Down
6 changes: 3 additions & 3 deletions ethcore/private-tx/src/private_state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ use error::Error;

/// Wrapper around local db with private state for sync purposes
pub struct PrivateStateDB {
db: Arc<KeyValueDB>,
db: Arc<dyn KeyValueDB>,
}

impl PrivateStateDB {
/// Constructs the object
pub fn new(db: Arc<KeyValueDB>) -> Self {
pub fn new(db: Arc<dyn KeyValueDB>) -> Self {
PrivateStateDB {
db,
}
Expand Down Expand Up @@ -59,4 +59,4 @@ impl PrivateStateDB {
pub fn state_hash(&self, state: &Bytes) -> Result<H256, Error> {
Ok(KeccakHasher::hash(state))
}
}
}
4 changes: 2 additions & 2 deletions ethcore/private-tx/src/state_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct PrivateStateStorage {

impl PrivateStateStorage {
/// Constructs the object
pub fn new(db: Arc<KeyValueDB>) -> Self {
pub fn new(db: Arc<dyn KeyValueDB>) -> Self {
PrivateStateStorage {
private_state_db: Arc::new(PrivateStateDB::new(db)),
requests: RwLock::new(Vec::new()),
Expand Down Expand Up @@ -162,4 +162,4 @@ impl PrivateStateStorage {
!delete_request
});
}
}
}
16 changes: 8 additions & 8 deletions ethcore/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,21 @@ pub struct ClientService {
client: Arc<Client>,
snapshot: Arc<SnapshotService>,
private_tx: Arc<PrivateTxService>,
database: Arc<BlockChainDB>,
database: Arc<dyn BlockChainDB>,
}

impl ClientService {
/// Start the `ClientService`.
pub fn start(
config: ClientConfig,
spec: &Spec,
blockchain_db: Arc<BlockChainDB>,
blockchain_db: Arc<dyn BlockChainDB>,
snapshot_path: &Path,
restoration_db_handler: Box<BlockChainDBHandler>,
restoration_db_handler: Box<dyn BlockChainDBHandler>,
_ipc_path: &Path,
miner: Arc<Miner>,
signer: Arc<Signer>,
encryptor: Box<ethcore_private_tx::Encryptor>,
signer: Arc<dyn Signer>,
encryptor: Box<dyn ethcore_private_tx::Encryptor>,
private_tx_conf: ethcore_private_tx::ProviderConfig,
private_encryptor_conf: ethcore_private_tx::EncryptorConfig,
) -> Result<ClientService, EthcoreError>
Expand Down Expand Up @@ -175,7 +175,7 @@ impl ClientService {
}

/// Get general IO interface
pub fn register_io_handler(&self, handler: Arc<IoHandler<ClientIoMessage<Client>> + Send>) -> Result<(), IoError> {
pub fn register_io_handler(&self, handler: Arc<dyn IoHandler<ClientIoMessage> + Send>) -> Result<(), IoError> {
self.io_service.register_handler(handler)
}

Expand All @@ -200,12 +200,12 @@ impl ClientService {
}

/// 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);
}

/// 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
pub fn shutdown(&self) {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/chain/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ impl SyncHandler {
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()) {
trace!(target: "sync", "{} Ignoring packet from unconfirmed/unknown peer", peer_id);
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ impl ChainSync {
}

/// 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();
if private_state_peers.is_empty() {
error!(target: "privatetx", "Cannot request private state, no peers with private tx enabled available");
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/chain/requester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl SyncRequester {
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);
let mut rlp = RlpStream::new_list(1);
rlp.append(hash);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/sync/src/chain/supplier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl SyncSupplier {
}

/// 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)?;
trace!(target: "privatetx", "{} -> GetPrivateStatePacket {:?}", peer_id, hash);
io.private_state().map_or(Ok(None), |db| {
Expand Down
Loading

0 comments on commit 22df32b

Please sign in to comment.