Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 27, 2022
1 parent cd0857b commit 13c119e
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 46 deletions.
9 changes: 4 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
// You should have received a copy of the MIT License along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

use std::env;
use std::fs;
use std::{env, fs};

use clap::IntoApp;
use clap_complete::generate_to;
Expand All @@ -35,9 +34,9 @@ fn main() -> Result<(), configure_me_codegen::Error> {
fs::create_dir_all(outdir).expect("failed to create shell dir");
for app in [rgbd::Opts::command(), bucketd::Opts::command()].iter_mut() {
let name = app.get_name().to_string();
generate_to(Bash, app, &name, &outdir)?;
generate_to(PowerShell, app, &name, &outdir)?;
generate_to(Zsh, app, &name, &outdir)?;
generate_to(Bash, app, &name, outdir)?;
generate_to(PowerShell, app, &name, outdir)?;
generate_to(Zsh, app, &name, outdir)?;
}
// configure_me_codegen::build_script_auto()
}
Expand Down
11 changes: 5 additions & 6 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ fn main() -> Result<(), configure_me_codegen::Error> {
if env::var("DOCS_RS").is_err() {
let outdir = "../shell";
fs::create_dir_all(outdir).expect("failed to create shell dir");
for app in [cli::Opts::command()].iter_mut() {
let name = app.get_name().to_string();
generate_to(Bash, app, &name, &outdir)?;
generate_to(PowerShell, app, &name, &outdir)?;
generate_to(Zsh, app, &name, &outdir)?;
}
let mut app = cli::Opts::command();
let name = app.get_name().to_string();
generate_to(Bash, &mut app, &name, outdir)?;
generate_to(PowerShell, &mut app, &name, outdir)?;
generate_to(Zsh, &mut app, &name, outdir)?;
}
// configure_me_codegen::build_script_auto()
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl Exec for Opts {

let outpoints: BTreeSet<_> =
psbt.inputs.iter().map(|input| input.previous_outpoint).collect();
let state_map = client.outpoint_state(outpoints.clone(), progress)?;
let state_map = client.outpoint_state(outpoints, progress)?;
for (cid, outpoint_map) in state_map {
if cid == contract_id {
continue;
Expand Down Expand Up @@ -286,7 +286,7 @@ impl Exec for Opts {
consignment,
reveal,
} => {
let consignment = StateTransfer::strict_file_load(&consignment)?;
let consignment = StateTransfer::strict_file_load(consignment)?;
let status = client.consume_transfer(consignment, force, reveal, progress)?;
report_validation(status);
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,6 @@ impl esb::Handler<RpcBus> for Handler {

fn handle_err(&mut self, _: &mut Bus, err: esb::Error<ServiceId>) -> Result<(), Self::Error> {
// We simply propagate the error since it already has been reported
Err(err.into())
Err(err)
}
}
10 changes: 10 additions & 0 deletions rpc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ impl Display for FailureCode {
impl From<u16> for FailureCode {
fn from(value: u16) -> Self {
match value {
x if x == FailureCode::ChainMismatch as u16 => FailureCode::ChainMismatch,
x if x == FailureCode::Encoding as u16 => FailureCode::Encoding,
x if x == FailureCode::Esb as u16 => FailureCode::Esb,
x if x == FailureCode::Store as u16 => FailureCode::Store,
x if x == FailureCode::Stash as u16 => FailureCode::Stash,
x if x == FailureCode::Absent as u16 => FailureCode::Absent,
x if x == FailureCode::Finalize as u16 => FailureCode::Finalize,
x if x == FailureCode::ElectrumConnectivity as u16 => FailureCode::ElectrumConnectivity,
x if x == FailureCode::UnexpectedRequest as u16 => FailureCode::UnexpectedRequest,
x if x == FailureCode::Launcher as u16 => FailureCode::Launcher,
_ => FailureCode::Unknown,
}
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/src/reveal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ::core::str::FromStr for Reveal {
return Err(ParseRevealError::TooLong);
}
let find_method = s.find('@');
if find_method == None {
if find_method.is_none() {
return Err(ParseRevealError::Format);
}

Expand All @@ -53,7 +53,7 @@ impl ::core::str::FromStr for Reveal {
}

let find_blind = s.find('#');
if find_blind == None {
if find_blind.is_none() {
return Err(ParseRevealError::Format);
}

Expand Down
10 changes: 5 additions & 5 deletions src/bucketd/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Runtime {
let chunk = self
.store
.retrieve_chunk(storm_rpc::DB_TABLE_CHUNKS, chunk_id)?
.expect(&format!("Chunk {} is absent", chunk_id));
.unwrap_or_else(|| panic!("Chunk {} is absent", chunk_id));
writer.write_all(chunk.as_slice()).expect("memory writers do not error");
}

Expand Down Expand Up @@ -227,7 +227,7 @@ impl Runtime {
method: close_method,
blinding: blinding_factor,
txid: Some(outpoint.txid),
vout: outpoint.vout as u32,
vout: outpoint.vout,
};

let concealed_seals = consignment
Expand Down Expand Up @@ -289,7 +289,7 @@ impl Runtime {
method: close_method,
blinding: blinding_factor,
txid: Some(outpoint.txid),
vout: outpoint.vout as u32,
vout: outpoint.vout,
};

let mut owned_rights: BTreeMap<OwnedRightType, TypedAssignments> = bmap! {};
Expand Down Expand Up @@ -400,7 +400,7 @@ impl Runtime {
debug!("Processing state extension {}", node_id);
trace!("State transition: {:?}", extension);

state.add_extension(&extension);
state.add_extension(extension);
trace!("Contract state now is {:?}", state);

self.store.store_sten(db::NODE_CONTRACTS, node_id, &contract_id)?;
Expand All @@ -425,7 +425,7 @@ impl Runtime {
.retrieve_sten(db::DISCLOSURES, txid)?
.ok_or(StashError::DisclosureAbsent(txid))?;

for (_anchor_id, (anchor, bundle_map)) in disclosure.anchored_bundles() {
for (anchor, bundle_map) in disclosure.anchored_bundles().values() {
for (contract_id, bundle) in bundle_map {
let mut state: ContractState = self
.store
Expand Down
8 changes: 2 additions & 6 deletions src/bucketd/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,8 @@ impl Runtime {
_client_id: ClientId,
message: RpcMsg,
) -> Result<(), DaemonError> {
match message {
wrong_msg => {
error!("Request is not supported by the RPC interface");
return Err(DaemonError::wrong_esb_msg(ServiceBus::Rpc, &wrong_msg));
}
}
error!("Request is not supported by the RPC interface");
Err(DaemonError::wrong_esb_msg(ServiceBus::Rpc, &message))
}

fn handle_ctl(
Expand Down
38 changes: 19 additions & 19 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
// You should have received a copy of the MIT License along with this software.
// If not, see <https://opensource.org/licenses/MIT>.

pub const SCHEMATA: &'static str = "schemata";
pub const CONTRACTS: &'static str = "contracts";
pub const BUNDLES: &'static str = "bundles";
pub const GENESIS: &'static str = "genesis";
pub const TRANSITIONS: &'static str = "transitions";
pub const ANCHORS: &'static str = "anchors";
pub const EXTENSIONS: &'static str = "extensions";
pub const ALU_LIBS: &'static str = "alu";

pub const OUTPOINTS: &'static str = "outpoints";
pub const NODE_CONTRACTS: &'static str = "node_contracts";
pub const TRANSITION_WITNESS: &'static str = "transition_txid";
pub const CONTRACT_TRANSITIONS: &'static str = "contract_transitions";

pub const DISCLOSURES: &'static str = "disclosures";
pub const SCHEMATA: &str = "schemata";
pub const CONTRACTS: &str = "contracts";
pub const BUNDLES: &str = "bundles";
pub const GENESIS: &str = "genesis";
pub const TRANSITIONS: &str = "transitions";
pub const ANCHORS: &str = "anchors";
pub const EXTENSIONS: &str = "extensions";
pub const ALU_LIBS: &str = "alu";

pub const OUTPOINTS: &str = "outpoints";
pub const NODE_CONTRACTS: &str = "node_contracts";
pub const TRANSITION_WITNESS: &str = "transition_txid";
pub const CONTRACT_TRANSITIONS: &str = "contract_transitions";

pub const DISCLOSURES: &str = "disclosures";

// Storm intgration
pub const ATTACHMENT_CHUNKS: &'static str = "chunks";
pub const ATTACHMENT_INDEX: &'static str = "attachments";
pub const ATTACHMENT_CONTAINER_HEADERS: &'static str = "container_headers";
pub const ATTACHMENT_CONTAINERS: &'static str = "containers";
pub const ATTACHMENT_CHUNKS: &str = "chunks";
pub const ATTACHMENT_INDEX: &str = "attachments";
pub const ATTACHMENT_CONTAINER_HEADERS: &str = "container_headers";
pub const ATTACHMENT_CONTAINERS: &str = "containers";

pub(crate) trait StoreRpcExt {
fn retrieve_sten<T>(
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
dead_code,
//missing_docs
)]
#![allow(clippy::result_large_err)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#[macro_use]
Expand Down

0 comments on commit 13c119e

Please sign in to comment.