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

chore: fix clippy lints from rust 1.78 #180

Merged
merged 3 commits into from
May 2, 2024
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
4 changes: 2 additions & 2 deletions basecoin/app/src/abci/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Contains various ABCI implementations to interact with different version of
//! underlying consensus engine (CometBFT)

#[cfg(all(feature = "v0_37", not(feature = "v0_38")))]
#[cfg(feature = "v0_37")]
pub mod v0_37;

#[cfg(all(feature = "v0_38", not(feature = "v0_37")))]
#[cfg(feature = "v0_38")]
pub mod v0_38;
16 changes: 8 additions & 8 deletions basecoin/app/src/abci/v0_38/tendermint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Debug;
use std::fmt::{Debug, Write};

use basecoin_modules::error::Error;
use basecoin_modules::types::IdentifiedModule;
Expand Down Expand Up @@ -64,14 +64,14 @@ impl<S: Debug + ProvableStore> Application for BaseCoinApp<S> {
fn query(&self, request: RequestQuery) -> ResponseQuery {
debug!("Got query request: {:?}", request);

let path: Option<Path> = request.path.try_into().ok();
let path = Path::from(request.path);

let modules = self.modules.read_access();

let height = Height::from(request.height as u64);

for IdentifiedModule { id, module } in modules.iter() {
match module.query(&request.data, path.as_ref(), height, request.prove) {
match module.query(&request.data, Some(&path), height, request.prove) {
// success - implies query was handled by this module, so return response
Ok(result) => {
let store = self.store.read_access();
Expand Down Expand Up @@ -99,10 +99,7 @@ impl<S: Debug + ProvableStore> Application for BaseCoinApp<S> {
log: "exists".to_string(),
key: request.data,
value: result.data.into(),
proof_ops: match proof_ops {
Some(proof_ops) => Some(proof_ops.into()),
None => None,
},
proof_ops: proof_ops.map(Into::into),
height: store.current_height() as i64,
..Default::default()
};
Expand Down Expand Up @@ -138,7 +135,10 @@ impl<S: Debug + ProvableStore> Application for BaseCoinApp<S> {
info!(
"Committed height {} with hash({})",
state.current_height() - 1,
data.iter().map(|b| format!("{b:02X}")).collect::<String>()
data.iter().fold(String::new(), |mut output, b| {
let _ = write!(output, "{b:02X}");
output
})
);
ResponseCommit { retain_height: 0 }
}
Expand Down
21 changes: 12 additions & 9 deletions basecoin/app/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#[cfg(any(feature = "v0_38", not(feature = "v0_37")))]
use tendermint_proto::abci::{ResponseCheckTx, ResponseQuery};
#[cfg(all(feature = "v0_37", not(feature = "v0_38")))]
use tendermint_proto::v0_37::abci::{ResponseCheckTx, ResponseDeliverTx, ResponseQuery};

#[cfg(any(feature = "v0_37", feature = "v0_38"))]
pub(crate) trait ResponseFromErrorExt {
fn from_error(code: u32, log: impl ToString) -> Self;
}

#[cfg(any(feature = "v0_37", feature = "v0_38"))]
macro_rules! impl_response_error_for {
($($resp:ty),+) => {
$(impl ResponseFromErrorExt for $resp {
Expand All @@ -22,8 +19,14 @@ macro_rules! impl_response_error_for {
};
}

#[cfg(all(feature = "v0_37", not(feature = "v0_38")))]
impl_response_error_for!(ResponseQuery, ResponseCheckTx, ResponseDeliverTx);
#[cfg(feature = "v0_37")]
const _: () = {
use tendermint_proto::v0_37::abci::{ResponseCheckTx, ResponseDeliverTx, ResponseQuery};
impl_response_error_for!(ResponseQuery, ResponseCheckTx, ResponseDeliverTx);
};

#[cfg(any(feature = "v0_38", not(feature = "v0_37")))]
impl_response_error_for!(ResponseQuery, ResponseCheckTx);
#[cfg(feature = "v0_38")]
const _: () = {
use tendermint_proto::abci::{ResponseCheckTx, ResponseQuery};
impl_response_error_for!(ResponseQuery, ResponseCheckTx);
};
Loading