Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow dead code and unused imports #680

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,14 @@
use crate::rpc::request::{Address, AddressSecretKey};
use crate::syncerd::{SweepBitcoinAddress, SweepMoneroAddress};
use farcaster_core::swap::btcxmr::Offer;
use std::{
convert::TryFrom,
io::{self, Read, Write},
sync::mpsc,
time::Duration,
};
use std::{str::FromStr, thread::sleep};
use std::io::Read;
use std::str::FromStr;
use uuid::Uuid;

use internet2::addr::{InetSocketAddr, NodeAddr};
use microservices::shell::Exec;

use farcaster_core::{
blockchain::{Blockchain, Network},
negotiation::PublicOffer,
role::{SwapRole, TradeRole},
swap::SwapId,
};
use strict_encoding::ReadExt;
use farcaster_core::{blockchain::Network, negotiation::PublicOffer, role::SwapRole, swap::SwapId};

use super::Command;
use crate::rpc::{request, Client, Request};
Expand Down
4 changes: 0 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use crate::Error;
use farcaster_core::blockchain::Network;
use internet2::addr::NodeAddr;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
Expand All @@ -29,9 +28,6 @@ pub const FARCASTER_TESTNET_ELECTRUM_SERVER: &str = "ssl://blockstream.info:993"
pub const FARCASTER_TESTNET_MONERO_DAEMON: &str = "http://stagenet.community.rino.io:38081";
pub const FARCASTER_TESTNET_MONERO_RPC_WALLET: &str = "http://localhost:38083";

#[cfg(feature = "shell")]
use crate::opts::Opts;

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(crate = "serde_crate")]
pub struct Config {
Expand Down
10 changes: 0 additions & 10 deletions src/databased/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,7 @@
// along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

use crate::opts::FARCASTER_KEY_FILE;
use clap::{AppSettings, Parser, ValueHint};
use std::path::PathBuf;
use std::{fs, io::Read};

use crate::opts::TokenString;
use bitcoin::secp256k1::{
rand::{rngs::ThreadRng, thread_rng},
PublicKey, Secp256k1, SecretKey,
};
use strict_encoding::{StrictDecode, StrictEncode};

/// database daemon; part of Farcaster Node
#[derive(Parser, Clone, PartialEq, Eq, Debug)]
Expand Down
34 changes: 8 additions & 26 deletions src/databased/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
use crate::databased::runtime::request::{
Address, OfferStatus, OfferStatusPair, OfferStatusSelector,
};
use crate::farcaster_core::consensus::Encodable;
use crate::walletd::runtime::{CheckpointWallet, Wallet};
use farcaster_core::blockchain::Blockchain;
use farcaster_core::swap::btcxmr::PublicOffer;
use farcaster_core::swap::SwapId;
use lmdb::{Cursor, Transaction as LMDBTransaction};
use std::convert::TryInto;
use std::path::PathBuf;
use std::{
any::Any,
collections::{HashMap, HashSet},
convert::{TryFrom, TryInto},
io::{self, Write},
ptr::swap_nonoverlapping,
str::FromStr,
};
use strict_encoding::StrictDecode;
use strict_encoding::StrictEncode;
use strict_encoding::{StrictDecode, StrictEncode};

use crate::swapd::get_swap_id;
use crate::Endpoints;
use crate::LogStyle;
use bitcoin::hashes::{ripemd160, Hash};
use bitcoin::secp256k1::SecretKey;

use crate::{
rpc::{
request::{
self, BitcoinAddress, Checkpoint, CheckpointEntry, CheckpointState, Commit, Failure,
FailureCode, Keys, LaunchSwap, List, MoneroAddress, Msg, NodeId, Params, Reveal, Token,
Tx,
},
Request, ServiceBus,
},
syncerd::SweepMoneroAddress,
use crate::rpc::{
request::{self, Checkpoint, CheckpointEntry, CheckpointState, Failure, FailureCode, List},
Request, ServiceBus,
};
use crate::{CtlServer, Error, Service, ServiceConfig, ServiceId};
use colored::Colorize;
use internet2::TypedEnum;
use microservices::esb::{self, Handler};
use microservices::esb;

pub fn run(config: ServiceConfig, data_dir: PathBuf) -> Result<(), Error> {
let runtime = Runtime {
Expand Down Expand Up @@ -645,6 +625,8 @@ impl Database {

#[test]
fn test_lmdb_state() {
use std::str::FromStr;

let val1 = vec![0, 1];
let val2 = vec![2, 3, 4, 5];
let key1 = CheckpointKey {
Expand Down
42 changes: 8 additions & 34 deletions src/farcasterd/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,28 @@ use crate::{
error::SyncerError,
rpc::request::{
BitcoinAddress, BitcoinFundingInfo, FundingInfo, Keys, LaunchSwap, MoneroAddress,
MoneroFundingInfo, OfferInfo, Outcome, PubOffer, RequestId, Reveal, Token,
MoneroFundingInfo, OfferInfo, Outcome, PubOffer, RequestId, Token,
},
service::Endpoints,
swapd::get_swap_id,
walletd::NodeSecrets,
};
use amplify::Wrapper;
use bitcoin::hashes::Hash as BitcoinHash;
use clap::IntoApp;
use request::{Commit, List, Params};
use std::collections::hash_map::Drain;
use std::collections::VecDeque;
use std::collections::{HashMap, HashSet};
use std::ffi::OsStr;
use std::io;
use std::iter::FromIterator;
use std::net::SocketAddr;
use std::process;
use std::time::{Duration, SystemTime};
use std::{collections::VecDeque, hash::Hash};
use std::{
collections::{HashMap, HashSet},
io::Read,
};
use std::{convert::TryFrom, thread::sleep};
use std::{convert::TryInto, ffi::OsStr};
use uuid::Uuid;

use bitcoin::{
hashes::hex::ToHex,
secp256k1::{PublicKey, SecretKey},
};
use bitcoin::{
secp256k1::{
self,
rand::{thread_rng, RngCore},
},
Address,
};
use bitcoin::{hashes::hex::ToHex, secp256k1::SecretKey};
use internet2::{
addr::NodeAddr,
addr::{InetSocketAddr, NodeId},
TypedEnum, UrlString,
TypedEnum,
};
use microservices::esb::{self, Handler};

Expand All @@ -72,17 +54,11 @@ use farcaster_core::{
};

use crate::farcasterd::Opts;
use crate::rpc::request::{
Failure, FailureCode, GetKeys, IntoProgressOrFailure, Msg, NodeInfo, OptionDetails,
};
use crate::rpc::request::{Failure, FailureCode, GetKeys, Msg, NodeInfo};
use crate::rpc::{request, Request, ServiceBus};
use crate::{Config, CtlServer, Error, LogStyle, Service, ServiceConfig, ServiceId};

use farcaster_core::{
blockchain::FeePriority,
role::TradeRole,
swap::btcxmr::{KeyManager, PublicOffer},
};
use farcaster_core::{role::TradeRole, swap::btcxmr::PublicOffer};

use std::str::FromStr;

Expand Down Expand Up @@ -1479,9 +1455,7 @@ impl Runtime {
);

use bitcoincore_rpc::{Auth, Client, Error, RpcApi};
use std::env;
use std::path::PathBuf;
use std::str::FromStr;

let host = auto_fund_config.bitcoin_rpc;
let bitcoin_rpc = match auto_fund_config.bitcoin_cookie_path {
Expand Down
8 changes: 0 additions & 8 deletions src/grpcd/opts.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
use crate::opts::FARCASTER_KEY_FILE;
use clap::ValueHint;
use std::path::PathBuf;
use std::{fs, io::Read};

use crate::opts::TokenString;
use strict_encoding::{StrictDecode, StrictEncode};

/// Grpcd daemon; part of Farcaster Node
#[derive(Parser, Clone, PartialEq, Eq, Debug)]
#[clap(name = "grpcd", bin_name = "grpcd", author, version)]
Expand Down
23 changes: 3 additions & 20 deletions src/grpcd/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,20 @@ use crate::service::Endpoints;
use internet2::DuplexConnection;
use internet2::Encrypt;
use internet2::PlainTranscoder;
use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
use std::{
any::Any,
collections::{HashMap, HashSet},
convert::{TryFrom, TryInto},
io::{self, Write},
ptr::swap_nonoverlapping,
str::FromStr,
};
use tokio::runtime::Builder;
use tokio::sync::Mutex;

use crate::rpc::{
request::{self},
Request, ServiceBus,
};
use crate::swapd::get_swap_id;
use crate::walletd::NodeSecrets;
use crate::LogStyle;
use crate::rpc::{Request, ServiceBus};
use crate::{CtlServer, Error, Service, ServiceConfig, ServiceId};
use colored::Colorize;
use internet2::{
addr::NodeAddr,
presentation, transport,
zeromq::{Connection, ZmqSocketType},
TypedEnum,
};
use microservices::esb::{self, Handler};
use microservices::esb;
use microservices::ZMQ_CONTEXT;
use request::{LaunchSwap, NodeId};
use std::sync::mpsc::{Receiver, Sender};

use farcaster::farcaster_server::{Farcaster, FarcasterServer};
Expand Down
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@
// You should have received a copy of the MIT License
// along with this software.
// If not, see <https://opensource.org/licenses/MIT>.
#![allow(unused_imports)]
#![recursion_limit = "256"]
// Coding conventions
#![deny(
non_upper_case_globals,
non_camel_case_types,
non_snake_case,
unused_mut,
// unused_imports,
// dead_code
// missing_docs,
unused_imports,
dead_code
)]

extern crate farcaster_core;
Expand All @@ -32,9 +30,6 @@ extern crate amplify;
extern crate amplify_derive;
// #[cfg_attr(feature = "_rpc", macro_use)]

#[macro_use]
extern crate internet2;

#[cfg(feature = "shell")]
#[macro_use]
extern crate clap;
Expand Down
8 changes: 3 additions & 5 deletions src/peerd/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
use internet2::addr::LocalNode;
use microservices::peer::PeerReceiver;
use microservices::peer::RecvMessage;
use std::thread::JoinHandle;
use std::sync::Arc;
use std::thread::spawn;
use std::time::{Duration, SystemTime};
use std::{collections::HashMap, sync::Arc};
use std::{rc::Rc, thread::spawn};

use amplify::Bipolar;
use bitcoin::secp256k1::rand::{self, Rng, RngCore};
use bitcoin::secp256k1::PublicKey;
use internet2::{addr::InetSocketAddr, CreateUnmarshaller, Unmarshall, Unmarshaller};
use internet2::{
addr::NodeAddr,
Expand All @@ -36,7 +34,7 @@ use microservices::peer::{self, PeerConnection, PeerSender, SendMessage};
use microservices::ZMQ_CONTEXT;

use crate::rpc::{
request::{self, Msg, PeerInfo, TakeCommit, Token},
request::{Msg, PeerInfo},
Request, ServiceBus,
};
use crate::{CtlServer, Endpoints, Error, LogStyle, Service, ServiceConfig, ServiceId};
Expand Down
5 changes: 1 addition & 4 deletions src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@
// If not, see <https://opensource.org/licenses/MIT>.

use crate::service::Endpoints;
use std::convert::TryInto;
use std::thread::{self, sleep};
use std::thread::sleep;
use std::time::Duration;

use internet2::ZmqSocketType;
use microservices::esb;

use crate::rpc::request::OptionDetails;
use crate::rpc::request::SwapProgress;
use crate::rpc::{Request, ServiceBus};
use crate::service::ServiceConfig;
use crate::{Error, LogStyle, ServiceId};
Expand Down
1 change: 0 additions & 1 deletion src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub use request::OfferStatusSelector;
pub use request::{Failure, FailureCode, Request};

use microservices::esb::BusId;
use microservices::rpc::Api;
use strict_encoding::{StrictDecode, StrictEncode};

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Display, StrictEncode, StrictDecode)]
Expand Down
Loading