Skip to content

Commit

Permalink
chore: fix lint warnings across the board
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Jan 4, 2024
1 parent 972102a commit 147d4b6
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
14 changes: 9 additions & 5 deletions examples/n2c-miniprotocols/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pallas::{
miniprotocols::{
chainsync,
localstate::queries_v16::{self, Addr, Addrs},
Point, PRE_PRODUCTION_MAGIC, PREVIEW_MAGIC
Point, PRE_PRODUCTION_MAGIC,
},
},
};
Expand Down Expand Up @@ -81,8 +81,8 @@ async fn do_chainsync(client: &mut NodeClient) {

// change the following to match the Cardano node socket in your local
// environment
#[cfg(unix)]
const SOCKET_PATH: &str = "/tmp/node.socket";
const PIPE_NAME: &str = "\\\\.\\pipe\\cardano-pallas";

#[cfg(unix)]
#[tokio::main]
Expand All @@ -107,20 +107,24 @@ async fn main() {
do_chainsync(&mut client).await;
}

// change the following to match the Cardano node named-pipe in your local
// environment
#[cfg(target_family = "windows")]
const PIPE_NAME: &str = "\\\\.\\pipe\\cardano-pallas";

#[cfg(target_family = "windows")]
#[tokio::main]
async fn main() {

tracing::subscriber::set_global_default(
tracing_subscriber::FmtSubscriber::builder()
.with_max_level(tracing::Level::TRACE)
.finish(),
)
.unwrap();

// we connect to the namedpipe of the local node. Make sure you have the right
// we connect to the named-pipe of the local node. Make sure you have the right
// path for your environment
let mut client = NodeClient::connect(PIPE_NAME, PREVIEW_MAGIC)
let mut client = NodeClient::connect(PIPE_NAME, PRE_PRODUCTION_MAGIC)
.await
.unwrap();

Expand Down
17 changes: 10 additions & 7 deletions pallas-hardano/src/storage/immutable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
path::{Path, PathBuf},
};

use pallas_network::miniprotocols::Point;
use pallas_traverse::MultiEraBlock;
use tap::Tap;
use thiserror::Error;
Expand All @@ -14,6 +13,10 @@ pub mod chunk;
pub mod primary;
pub mod secondary;

// TODO: we should make Point accessible in some crate more generic that
// `network`.
pub type Point = pallas_network::miniprotocols::Point;

#[derive(Debug, Error, PartialEq, Eq)]
pub enum Error {
#[error("Cannot find block by the provided point: {0:?}")]
Expand Down Expand Up @@ -164,10 +167,10 @@ pub fn read_blocks(dir: &Path) -> Result<impl Iterator<Item = FallibleBlock>, st
///
/// # Example
///
/// ```rust
/// ```no_run
/// use std::path::Path;
/// use std::error::Error;
/// use crate::{Point, read_blocks_from_point};
/// use pallas_hardano::storage::immutable::{Point, read_blocks_from_point};
///
/// fn main() -> Result<(), Box<dyn Error>> {
/// let dir = Path::new("/path/to/blocks");
Expand Down Expand Up @@ -211,7 +214,7 @@ pub fn read_blocks_from_point(
// check the first block
match iter.peek() {
Some(Ok(block_data)) => {
let block = MultiEraBlock::decode(&block_data)?;
let block = MultiEraBlock::decode(block_data)?;
// check that the first block is genesis
if block.slot() == 0 && block.number() == 0 {
Ok(Box::new(iter))
Expand All @@ -229,7 +232,7 @@ pub fn read_blocks_from_point(
// and compares block's slot with provided slot number
let cmp = {
|chunk_name: &String, point: &u64| {
let mut blocks = chunk::read_blocks(dir, &chunk_name)?;
let mut blocks = chunk::read_blocks(dir, chunk_name)?;

// Try to read the first block from the chunk
if let Some(block_data) = blocks.next() {
Expand Down Expand Up @@ -275,10 +278,10 @@ pub fn read_blocks_from_point(
///
/// # Example
///
/// ```rust
/// ```no_run
/// use std::path::Path;
/// use std::error::Error;
/// use crate::{Point, get_tip};
/// use pallas_hardano::storage::immutable::{Point, get_tip};
///
/// fn main() -> Result<(), Box<dyn Error>> {
/// let dir = Path::new("/path/to/blocks");
Expand Down
10 changes: 4 additions & 6 deletions pallas-network/src/facades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,10 @@ impl NodeClient {
) -> Result<Self, Error> {
let pipe_name = pipe_name.as_ref().to_os_string();

let bearer = tokio::task::spawn_blocking(move || {
Bearer::connect_named_pipe(pipe_name)
})
.await
.expect("can't join tokio thread")
.map_err(Error::ConnectFailure)?;
let bearer = tokio::task::spawn_blocking(move || Bearer::connect_named_pipe(pipe_name))
.await
.expect("can't join tokio thread")
.map_err(Error::ConnectFailure)?;

let mut client = Self::new(bearer);

Expand Down
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/blockfetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ mod protocol;
mod server;

pub use client::*;
pub use codec::*;
pub use protocol::*;
pub use server::*;
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/chainsync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ mod server;

pub use buffer::*;
pub use client::*;
pub use codec::*;
pub use protocol::*;
pub use server::*;
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/keepalive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ mod codec;
mod protocol;

pub use client::*;
pub use codec::*;
pub use protocol::*;
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/localstate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ mod server;
pub mod queries_v16;

pub use client::*;
pub use codec::*;
pub use protocol::*;
pub use server::*;
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/localtxsubmission/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub use client::*;
pub use codec::*;
pub use protocol::*;

mod client;
Expand Down
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/txmonitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ mod codec;
mod protocol;

pub use client::*;
pub use codec::*;
pub use protocol::*;
1 change: 0 additions & 1 deletion pallas-network/src/miniprotocols/txsubmission/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ mod protocol;
mod server;

pub use client::*;
pub use codec::*;
pub use protocol::*;
pub use server::*;
12 changes: 7 additions & 5 deletions pallas-network/src/multiplexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::HashMap;
use byteorder::{ByteOrder, NetworkEndian};
use pallas_codec::{minicbor, Fragment};
use thiserror::Error;
use tokio::io::{AsyncReadExt, AsyncWriteExt, ReadHalf, WriteHalf};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::task::JoinHandle;
use tokio::time::Instant;
use tokio::{select, sync::mpsc::error::SendError};
Expand All @@ -21,6 +21,9 @@ use tokio::net as unix;
#[cfg(windows)]
use tokio::net::windows::named_pipe::NamedPipeClient;

#[cfg(windows)]
use tokio::io::{ReadHalf, WriteHalf};

const HEADER_LEN: usize = 8;

pub type Timestamp = u32;
Expand Down Expand Up @@ -126,9 +129,8 @@ impl Bearer {
}

#[cfg(windows)]
pub fn connect_named_pipe(pipe_name: impl AsRef<std::ffi::OsStr>) ->
IOResult<Self> { let client =
tokio::net::windows::named_pipe::ClientOptions::new().open(&pipe_name)?;
pub fn connect_named_pipe(pipe_name: impl AsRef<std::ffi::OsStr>) -> IOResult<Self> {
let client = tokio::net::windows::named_pipe::ClientOptions::new().open(&pipe_name)?;
Ok(Self::NamedPipe(client))
}

Expand Down Expand Up @@ -174,7 +176,7 @@ impl BearerReadHalf {

#[cfg(unix)]
BearerReadHalf::Unix(x) => x.read_exact(buf).await,

#[cfg(windows)]
BearerReadHalf::NamedPipe(x) => x.read_exact(buf).await,
}
Expand Down
2 changes: 1 addition & 1 deletion pallas-wallet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use ed25519_bip32;
use pallas_crypto::key::ed25519::{PublicKey, SecretKey, SecretKeyExtended, Signature};
use thiserror::Error;

Expand Down Expand Up @@ -40,6 +39,7 @@ pub enum PrivateKey {
}

impl PrivateKey {
#[allow(clippy::len_without_is_empty)]
pub fn len(&self) -> usize {
match self {
Self::Normal(_) => SecretKey::SIZE,
Expand Down

0 comments on commit 147d4b6

Please sign in to comment.