Skip to content

Commit

Permalink
cleanup deprecation warnings about missing dyn with trait objects (#2997
Browse files Browse the repository at this point in the history
)
  • Loading branch information
antiochp authored Aug 26, 2019
1 parent d06b56c commit dcd405e
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ impl Chain {
/// Currently does not write these to disk and simply deserializes
/// the provided data.
/// TODO - Write this data to disk and validate the rebuilt kernel MMR.
pub fn kernel_data_write(&self, reader: &mut Read) -> Result<(), Error> {
pub fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<(), Error> {
let mut count = 0;
let mut stream = StreamingReader::new(reader, ProtocolVersion::local());
while let Ok(_kernel) = TxKernelEntry::read(&mut stream) {
Expand Down Expand Up @@ -1390,7 +1390,7 @@ fn setup_head(
batch.save_header_head(&tip)?;

if genesis.kernels().len() > 0 {
let (utxo_sum, kernel_sum) = (sums, genesis as &Committed).verify_kernel_sums(
let (utxo_sum, kernel_sum) = (sums, genesis as &dyn Committed).verify_kernel_sums(
genesis.header.overage(),
genesis.header.total_kernel_offset(),
)?;
Expand Down
2 changes: 1 addition & 1 deletion core/src/core/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub struct HeaderEntry {
}

impl Readable for HeaderEntry {
fn read(reader: &mut Reader) -> Result<HeaderEntry, ser::Error> {
fn read(reader: &mut dyn Reader) -> Result<HeaderEntry, ser::Error> {
let hash = Hash::read(reader)?;
let timestamp = reader.read_u64()?;
let total_difficulty = Difficulty::read(reader)?;
Expand Down
2 changes: 1 addition & 1 deletion core/src/core/pmmr/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub trait Backend<T: PMMRable> {
fn get_data_from_file(&self, position: u64) -> Option<T::E>;

/// Iterator over current (unpruned, unremoved) leaf positions.
fn leaf_pos_iter(&self) -> Box<Iterator<Item = u64> + '_>;
fn leaf_pos_iter(&self) -> Box<dyn Iterator<Item = u64> + '_>;

/// Remove Hash by insertion position. An index is also provided so the
/// underlying backend can implement some rollback of positions up to a
Expand Down
2 changes: 1 addition & 1 deletion core/src/core/pmmr/rewindable_pmmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ where
}

/// Reference to the underlying storage backend.
pub fn backend(&'a self) -> &Backend<T> {
pub fn backend(&'a self) -> &dyn Backend<T> {
self.backend
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl ChainAdapter for TrackingAdapter {
self.adapter.kernel_data_read()
}

fn kernel_data_write(&self, reader: &mut Read) -> Result<bool, chain::Error> {
fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, chain::Error> {
self.adapter.kernel_data_write(reader)
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/src/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl ChainAdapter for Peers {
self.adapter.kernel_data_read()
}

fn kernel_data_write(&self, reader: &mut Read) -> Result<bool, chain::Error> {
fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, chain::Error> {
self.adapter.kernel_data_write(reader)
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/src/serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl ChainAdapter for DummyAdapter {
fn kernel_data_read(&self) -> Result<File, chain::Error> {
unimplemented!()
}
fn kernel_data_write(&self, _reader: &mut Read) -> Result<bool, chain::Error> {
fn kernel_data_write(&self, _reader: &mut dyn Read) -> Result<bool, chain::Error> {
unimplemented!()
}
fn txhashset_read(&self, _h: Hash) -> Option<TxHashSetRead> {
Expand Down
2 changes: 1 addition & 1 deletion p2p/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ pub trait ChainAdapter: Sync + Send {

fn kernel_data_read(&self) -> Result<File, chain::Error>;

fn kernel_data_write(&self, reader: &mut Read) -> Result<bool, chain::Error>;
fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, chain::Error>;

/// Provides a reading view into the current txhashset state as well as
/// the required indexes for a consumer to rewind to a consistant state
Expand Down
2 changes: 1 addition & 1 deletion servers/src/common/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl p2p::ChainAdapter for NetToChainAdapter {
self.chain().kernel_data_read()
}

fn kernel_data_write(&self, reader: &mut Read) -> Result<bool, chain::Error> {
fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, chain::Error> {
let res = self.chain().kernel_data_write(reader)?;
error!("***** kernel_data_write: {:?}", res);
Ok(true)
Expand Down
4 changes: 2 additions & 2 deletions servers/src/common/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use tokio::runtime::Runtime;

/// Returns the list of event hooks that will be initialized for network events
pub fn init_net_hooks(config: &ServerConfig) -> Vec<Box<dyn NetEvents + Send + Sync>> {
let mut list: Vec<Box<NetEvents + Send + Sync>> = Vec::new();
let mut list: Vec<Box<dyn NetEvents + Send + Sync>> = Vec::new();
list.push(Box::new(EventLogger));
if config.webhook_config.block_received_url.is_some()
|| config.webhook_config.tx_received_url.is_some()
Expand All @@ -50,7 +50,7 @@ pub fn init_net_hooks(config: &ServerConfig) -> Vec<Box<dyn NetEvents + Send + S

/// Returns the list of event hooks that will be initialized for chain events
pub fn init_chain_hooks(config: &ServerConfig) -> Vec<Box<dyn ChainEvents + Send + Sync>> {
let mut list: Vec<Box<ChainEvents + Send + Sync>> = Vec::new();
let mut list: Vec<Box<dyn ChainEvents + Send + Sync>> = Vec::new();
list.push(Box::new(EventLogger));
if config.webhook_config.block_accepted_url.is_some() {
list.push(Box::new(WebHook::from_config(&config.webhook_config)));
Expand Down
4 changes: 2 additions & 2 deletions servers/src/grin/dandelion_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::util::{RwLock, StopState};
pub fn monitor_transactions(
dandelion_config: DandelionConfig,
tx_pool: Arc<RwLock<TransactionPool>>,
adapter: Arc<DandelionAdapter>,
adapter: Arc<dyn DandelionAdapter>,
verifier_cache: Arc<RwLock<dyn VerifierCache>>,
stop_state: Arc<StopState>,
) -> std::io::Result<thread::JoinHandle<()>> {
Expand Down Expand Up @@ -102,7 +102,7 @@ fn select_txs_cutoff(pool: &Pool, cutoff_secs: u16) -> Vec<PoolEntry> {
fn process_fluff_phase(
dandelion_config: &DandelionConfig,
tx_pool: &Arc<RwLock<TransactionPool>>,
adapter: &Arc<DandelionAdapter>,
adapter: &Arc<dyn DandelionAdapter>,
verifier_cache: &Arc<RwLock<dyn VerifierCache>>,
) -> Result<(), PoolError> {
// Take a write lock on the txpool for the duration of this processing.
Expand Down
4 changes: 2 additions & 2 deletions store/src/pmmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<T: PMMRable> Backend<T> for PMMRBackend<T> {
/// Returns an iterator over all the leaf positions.
/// for a prunable PMMR this is an iterator over the leaf_set bitmap.
/// For a non-prunable PMMR this is *all* leaves (this is not yet implemented).
fn leaf_pos_iter(&self) -> Box<Iterator<Item = u64> + '_> {
fn leaf_pos_iter(&self) -> Box<dyn Iterator<Item = u64> + '_> {
if self.prunable {
Box::new(self.leaf_set.iter())
} else {
Expand Down Expand Up @@ -472,7 +472,7 @@ pub fn clean_files_by_prefix<P: AsRef<std::path::Path>>(

let number_of_files_deleted: u32 = fs::read_dir(&path)?
.flat_map(
|possible_dir_entry| -> Result<u32, Box<std::error::Error>> {
|possible_dir_entry| -> Result<u32, Box<dyn std::error::Error>> {
// result implements iterator and so if we were to use map here
// we would have a list of Result<u32, Box<std::error::Error>>
// but because we use flat_map, the errors get "discarded" and we are
Expand Down

0 comments on commit dcd405e

Please sign in to comment.