Skip to content

Commit

Permalink
Update toolchain to nightly-2021-09-18
Browse files Browse the repository at this point in the history
This seemingly innoucous update required several changes due to changes
in how the compiler interprets dead code.

* A few variables were renamed _x where it looked like x might be used
  in upcoming PRs. YAGNI maybe, but I gave the benefit of the doubt in
this cases.
* Some crates that had LOADS of dead code (ffi crate I'm looking at
  you), I just changed the `deny(dead_code)` to `warn(dead_code)`
* And in some places, I just nuked the dead code, which tidied up some
  heavy code in the wallet in particular. Since the tests pass, I
presume this is fine and there isn't a weird new compioler bug that is
missing where the code is needed.
  • Loading branch information
CjS77 committed Oct 30, 2021
1 parent fad8520 commit 44716f2
Show file tree
Hide file tree
Showing 20 changed files with 389 additions and 440 deletions.
693 changes: 346 additions & 347 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 7 additions & 28 deletions applications/tari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ pub enum TransactionStage {
}

#[derive(Debug)]
pub struct SentTransaction {
id: TxId,
stage: TransactionStage,
}
pub struct SentTransaction {}

fn get_transaction_parameters(
args: Vec<ParsedArgument>,
Expand Down Expand Up @@ -453,10 +450,7 @@ pub async fn monitor_transactions(
"tx direct send event for tx_id: {}, success: {}", *id, success
);
if wait_stage == TransactionStage::DirectSendOrSaf {
results.push(SentTransaction {
id: *id,
stage: TransactionStage::DirectSendOrSaf,
});
results.push(SentTransaction {});
if results.len() == tx_ids.len() {
break;
}
Expand All @@ -468,10 +462,7 @@ pub async fn monitor_transactions(
"tx store and forward event for tx_id: {}, success: {}", *id, success
);
if wait_stage == TransactionStage::DirectSendOrSaf {
results.push(SentTransaction {
id: *id,
stage: TransactionStage::DirectSendOrSaf,
});
results.push(SentTransaction {});
if results.len() == tx_ids.len() {
break;
}
Expand All @@ -480,10 +471,7 @@ pub async fn monitor_transactions(
TransactionEvent::ReceivedTransactionReply(id) if tx_ids.contains(id) => {
debug!(target: LOG_TARGET, "tx reply event for tx_id: {}", *id);
if wait_stage == TransactionStage::Negotiated {
results.push(SentTransaction {
id: *id,
stage: TransactionStage::Negotiated,
});
results.push(SentTransaction {});
if results.len() == tx_ids.len() {
break;
}
Expand All @@ -492,10 +480,7 @@ pub async fn monitor_transactions(
TransactionEvent::TransactionBroadcast(id) if tx_ids.contains(id) => {
debug!(target: LOG_TARGET, "tx mempool broadcast event for tx_id: {}", *id);
if wait_stage == TransactionStage::Broadcast {
results.push(SentTransaction {
id: *id,
stage: TransactionStage::Broadcast,
});
results.push(SentTransaction {});
if results.len() == tx_ids.len() {
break;
}
Expand All @@ -514,10 +499,7 @@ pub async fn monitor_transactions(
is_valid
);
if wait_stage == TransactionStage::MinedUnconfirmed {
results.push(SentTransaction {
id: *tx_id,
stage: TransactionStage::MinedUnconfirmed,
});
results.push(SentTransaction {});
if results.len() == tx_ids.len() {
break;
}
Expand All @@ -529,10 +511,7 @@ pub async fn monitor_transactions(
"tx mined confirmed event for tx_id: {}, is_valid:{}", *tx_id, is_valid
);
if wait_stage == TransactionStage::Mined {
results.push(SentTransaction {
id: *tx_id,
stage: TransactionStage::Mined,
});
results.push(SentTransaction {});
if results.len() == tx_ids.len() {
break;
}
Expand Down
3 changes: 0 additions & 3 deletions applications/tari_console_wallet/src/ui/state/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ use crate::{
utils::db::{CUSTOM_BASE_NODE_ADDRESS_KEY, CUSTOM_BASE_NODE_PUBLIC_KEY_KEY},
wallet_modes::PeerConfig,
};
use tari_wallet::output_manager_service::handle::OutputManagerHandle;

const LOG_TARGET: &str = "wallet::console_wallet::app_state";

Expand All @@ -91,7 +90,6 @@ pub struct AppState {
node_config: GlobalConfig,
config: AppStateConfig,
wallet_connectivity: WalletConnectivityHandle,
output_manager_service: OutputManagerHandle,
balance_enquiry_debouncer: BalanceEnquiryDebouncer,
}

Expand All @@ -118,7 +116,6 @@ impl AppState {
node_config: node_config.clone(),
config: AppStateConfig::default(),
wallet_connectivity,
output_manager_service: output_manager_service.clone(),
balance_enquiry_debouncer: BalanceEnquiryDebouncer::new(
inner,
Duration::from_secs(node_config.wallet_balance_enquiry_cooldown_period),
Expand Down
8 changes: 4 additions & 4 deletions applications/tari_stratum_transcoder/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ impl StratumTranscoderProxyService {
) -> Self {
Self {
inner: InnerService {
config,
http_client,
_config: config,
_http_client: http_client,
base_node_client,
wallet_client,
},
Expand Down Expand Up @@ -129,8 +129,8 @@ impl Service<Request<Body>> for StratumTranscoderProxyService {

#[derive(Debug, Clone)]
struct InnerService {
config: StratumTranscoderProxyConfig,
http_client: reqwest::Client,
_config: StratumTranscoderProxyConfig,
_http_client: reqwest::Client,
base_node_client: grpc::base_node_client::BaseNodeClient<tonic::transport::Channel>,
wallet_client: grpc::wallet_client::WalletClient<tonic::transport::Channel>,
}
Expand Down
4 changes: 2 additions & 2 deletions base_layer/core/src/proof_of_work/randomx_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct RandomXVMInstance {
// The cache and dataset for the VM need to be stored together with it since they are not
// mix and match.
instance: Arc<Mutex<(RandomXVM, RandomXCache, Option<RandomXDataset>)>>,
flags: RandomXFlag,
_flags: RandomXFlag,
}

impl RandomXVMInstance {
Expand Down Expand Up @@ -48,7 +48,7 @@ impl RandomXVMInstance {

Ok(Self {
instance: Arc::new(Mutex::new((vm, cache, None))),
flags,
_flags: flags,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ pub const LOG_TARGET: &str = "c::tx::tx_protocol::tx_initializer";
/// SenderTransactionProtocol::new(1);
/// ```
/// which returns an instance of this builder. Once all the sender's information has been added via the builder
/// methods, you can call `build()` which will return a
/// methods, you can call `build()` which will return a [SenderTransactionProtocol]
#[derive(Debug, Clone)]
pub struct SenderTransactionInitializer {
consensus_constants: ConsensusConstants,
num_recipients: usize,
amounts: FixedSet<MicroTari>,
lock_height: Option<u64>,
Expand Down Expand Up @@ -113,7 +112,6 @@ impl SenderTransactionInitializer {
pub fn new(num_recipients: usize, consensus_constants: ConsensusConstants) -> Self {
Self {
fee: Fee::new(*consensus_constants.transaction_weight()),
consensus_constants,
num_recipients,
amounts: FixedSet::new(num_recipients),
lock_height: None,
Expand Down
22 changes: 11 additions & 11 deletions base_layer/p2p/src/comms_connector/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,37 +179,37 @@ mod test {
#[derive(Debug, Clone)]
struct Dummy {
a: u32,
b: String,
_b: String,
}

let messages = vec![
TopicPayload::new("Topic1", Dummy {
a: 1u32,
b: "one".to_string(),
_b: "one".to_string(),
}),
TopicPayload::new("Topic2", Dummy {
a: 2u32,
b: "two".to_string(),
_b: "two".to_string(),
}),
TopicPayload::new("Topic1", Dummy {
a: 3u32,
b: "three".to_string(),
_b: "three".to_string(),
}),
TopicPayload::new("Topic2", Dummy {
a: 4u32,
b: "four".to_string(),
_b: "four".to_string(),
}),
TopicPayload::new("Topic1", Dummy {
a: 5u32,
b: "five".to_string(),
_b: "five".to_string(),
}),
TopicPayload::new("Topic2", Dummy {
a: 6u32,
b: "size".to_string(),
_b: "size".to_string(),
}),
TopicPayload::new("Topic1", Dummy {
a: 7u32,
b: "seven".to_string(),
_b: "seven".to_string(),
}),
];

Expand All @@ -231,15 +231,15 @@ mod test {
let messages2 = vec![
TopicPayload::new("Topic1", Dummy {
a: 11u32,
b: "one one".to_string(),
_b: "one one".to_string(),
}),
TopicPayload::new("Topic2", Dummy {
a: 22u32,
b: "two two".to_string(),
_b: "two two".to_string(),
}),
TopicPayload::new("Topic1", Dummy {
a: 33u32,
b: "three three".to_string(),
_b: "three three".to_string(),
}),
];

Expand Down
8 changes: 4 additions & 4 deletions base_layer/p2p/src/dns/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl DnsClient {
#[derive(Clone)]
pub struct Client<C> {
inner: C,
shutdown: Arc<Shutdown>,
_shutdown: Arc<Shutdown>,
}

impl Client<AsyncDnssecClient> {
Expand All @@ -121,7 +121,7 @@ impl Client<AsyncDnssecClient> {

Ok(Self {
inner: client,
shutdown: Arc::new(shutdown),
_shutdown: Arc::new(shutdown),
})
}
}
Expand All @@ -135,7 +135,7 @@ impl Client<AsyncClient> {

Ok(Self {
inner: client,
shutdown: Arc::new(shutdown),
_shutdown: Arc::new(shutdown),
})
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ mod mock {
let client = MockClientHandle::mock(messages);
Ok(Self {
inner: client,
shutdown: Arc::new(Shutdown::new()),
_shutdown: Arc::new(Shutdown::new()),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions base_layer/p2p/src/dns/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use trust_dns_client::{
#[derive(Clone)]
pub struct MockClientHandle<O: OnSend, E> {
messages: Arc<Vec<Result<DnsResponse, E>>>,
on_send: O,
_on_send: O,
}

impl<E> MockClientHandle<DefaultOnSend, E> {
Expand All @@ -44,7 +44,7 @@ impl<E> MockClientHandle<DefaultOnSend, E> {

MockClientHandle {
messages: Arc::new(messages),
on_send: DefaultOnSend,
_on_send: DefaultOnSend,
}
}
}
Expand Down
1 change: 0 additions & 1 deletion base_layer/p2p/src/services/liveness/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ pub struct LivenessState {
pongs_received: usize,
pings_sent: usize,
pongs_sent: usize,
num_active_peers: usize,

local_metadata: Metadata,
}
Expand Down
3 changes: 0 additions & 3 deletions base_layer/wallet/src/output_manager_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use crate::{
service::OutputManagerService,
storage::database::{OutputManagerBackend, OutputManagerDatabase},
},
transaction_service::handle::TransactionServiceHandle,
};
use futures::future;
use log::*;
Expand Down Expand Up @@ -114,13 +113,11 @@ where T: OutputManagerBackend + 'static
let constants = self.network.create_consensus_constants().pop().unwrap();
let master_secret_key = self.master_secret_key.clone();
context.spawn_when_ready(move |handles| async move {
let transaction_service = handles.expect_handle::<TransactionServiceHandle>();
let base_node_service_handle = handles.expect_handle::<BaseNodeServiceHandle>();
let connectivity = handles.expect_handle::<WalletConnectivityHandle>();

let service = OutputManagerService::new(
config,
transaction_service,
receiver,
OutputManagerDatabase::new(backend),
publisher,
Expand Down
14 changes: 5 additions & 9 deletions base_layer/wallet/src/output_manager_service/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use crate::{
output_manager_service::{
config::OutputManagerServiceConfig,
handle::OutputManagerEventSender,
storage::database::OutputManagerDatabase,
MasterKeyManager,
},
transaction_service::handle::TransactionServiceHandle,
use crate::output_manager_service::{
config::OutputManagerServiceConfig,
handle::OutputManagerEventSender,
storage::database::OutputManagerDatabase,
MasterKeyManager,
};
use std::sync::Arc;
use tari_core::{consensus::ConsensusConstants, transactions::CryptoFactories};
Expand All @@ -38,7 +35,6 @@ use tari_shutdown::ShutdownSignal;
pub(crate) struct OutputManagerResources<TBackend, TWalletConnectivity> {
pub config: OutputManagerServiceConfig,
pub db: OutputManagerDatabase<TBackend>,
pub transaction_service: TransactionServiceHandle,
pub factories: CryptoFactories,
pub event_publisher: OutputManagerEventSender,
pub master_key_manager: Arc<MasterKeyManager<TBackend>>,
Expand Down
3 changes: 0 additions & 3 deletions base_layer/wallet/src/output_manager_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use crate::{
tasks::TxoValidationTask,
MasterKeyManager,
},
transaction_service::handle::TransactionServiceHandle,
types::HashDigest,
};
use blake2::Digest;
Expand Down Expand Up @@ -95,7 +94,6 @@ where
#[allow(clippy::too_many_arguments)]
pub async fn new(
config: OutputManagerServiceConfig,
transaction_service: TransactionServiceHandle,
request_stream: reply_channel::Receiver<
OutputManagerRequest,
Result<OutputManagerResponse, OutputManagerError>,
Expand All @@ -118,7 +116,6 @@ where
let resources = OutputManagerResources {
config,
db,
transaction_service,
factories,
connectivity,
event_publisher,
Expand Down
Loading

0 comments on commit 44716f2

Please sign in to comment.