chore: fix lint warnings across the board (#374)
This commit is contained in:
parent
50af4e0a75
commit
8c1ab39539
12 changed files with 31 additions and 31 deletions
|
|
@ -5,7 +5,7 @@ use pallas::{
|
||||||
miniprotocols::{
|
miniprotocols::{
|
||||||
chainsync,
|
chainsync,
|
||||||
localstate::queries_v16::{self, Addr, Addrs},
|
localstate::queries_v16::{self, Addr, Addrs},
|
||||||
Point, PRE_PRODUCTION_MAGIC, PREVIEW_MAGIC
|
Point, PRE_PRODUCTION_MAGIC,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -81,8 +81,8 @@ async fn do_chainsync(client: &mut NodeClient) {
|
||||||
|
|
||||||
// change the following to match the Cardano node socket in your local
|
// change the following to match the Cardano node socket in your local
|
||||||
// environment
|
// environment
|
||||||
|
#[cfg(unix)]
|
||||||
const SOCKET_PATH: &str = "/tmp/node.socket";
|
const SOCKET_PATH: &str = "/tmp/node.socket";
|
||||||
const PIPE_NAME: &str = "\\\\.\\pipe\\cardano-pallas";
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
@ -107,10 +107,14 @@ async fn main() {
|
||||||
do_chainsync(&mut client).await;
|
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")]
|
#[cfg(target_family = "windows")]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
||||||
tracing::subscriber::set_global_default(
|
tracing::subscriber::set_global_default(
|
||||||
tracing_subscriber::FmtSubscriber::builder()
|
tracing_subscriber::FmtSubscriber::builder()
|
||||||
.with_max_level(tracing::Level::TRACE)
|
.with_max_level(tracing::Level::TRACE)
|
||||||
|
|
@ -118,9 +122,9 @@ async fn main() {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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
|
// path for your environment
|
||||||
let mut client = NodeClient::connect(PIPE_NAME, PREVIEW_MAGIC)
|
let mut client = NodeClient::connect(PIPE_NAME, PRE_PRODUCTION_MAGIC)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use pallas_network::miniprotocols::Point;
|
|
||||||
use pallas_traverse::MultiEraBlock;
|
use pallas_traverse::MultiEraBlock;
|
||||||
use tap::Tap;
|
use tap::Tap;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
@ -14,6 +13,10 @@ pub mod chunk;
|
||||||
pub mod primary;
|
pub mod primary;
|
||||||
pub mod secondary;
|
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)]
|
#[derive(Debug, Error, PartialEq, Eq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Cannot find block by the provided point: {0:?}")]
|
#[error("Cannot find block by the provided point: {0:?}")]
|
||||||
|
|
@ -164,10 +167,10 @@ pub fn read_blocks(dir: &Path) -> Result<impl Iterator<Item = FallibleBlock>, st
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// use std::path::Path;
|
/// use std::path::Path;
|
||||||
/// use std::error::Error;
|
/// 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>> {
|
/// fn main() -> Result<(), Box<dyn Error>> {
|
||||||
/// let dir = Path::new("/path/to/blocks");
|
/// let dir = Path::new("/path/to/blocks");
|
||||||
|
|
@ -211,7 +214,7 @@ pub fn read_blocks_from_point(
|
||||||
// check the first block
|
// check the first block
|
||||||
match iter.peek() {
|
match iter.peek() {
|
||||||
Some(Ok(block_data)) => {
|
Some(Ok(block_data)) => {
|
||||||
let block = MultiEraBlock::decode(&block_data)?;
|
let block = MultiEraBlock::decode(block_data)?;
|
||||||
// check that the first block is genesis
|
// check that the first block is genesis
|
||||||
if block.slot() == 0 && block.number() == 0 {
|
if block.slot() == 0 && block.number() == 0 {
|
||||||
Ok(Box::new(iter))
|
Ok(Box::new(iter))
|
||||||
|
|
@ -229,7 +232,7 @@ pub fn read_blocks_from_point(
|
||||||
// and compares block's slot with provided slot number
|
// and compares block's slot with provided slot number
|
||||||
let cmp = {
|
let cmp = {
|
||||||
|chunk_name: &String, point: &u64| {
|
|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
|
// Try to read the first block from the chunk
|
||||||
if let Some(block_data) = blocks.next() {
|
if let Some(block_data) = blocks.next() {
|
||||||
|
|
@ -275,10 +278,10 @@ pub fn read_blocks_from_point(
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// use std::path::Path;
|
/// use std::path::Path;
|
||||||
/// use std::error::Error;
|
/// use std::error::Error;
|
||||||
/// use crate::{Point, get_tip};
|
/// use pallas_hardano::storage::immutable::{Point, get_tip};
|
||||||
///
|
///
|
||||||
/// fn main() -> Result<(), Box<dyn Error>> {
|
/// fn main() -> Result<(), Box<dyn Error>> {
|
||||||
/// let dir = Path::new("/path/to/blocks");
|
/// let dir = Path::new("/path/to/blocks");
|
||||||
|
|
|
||||||
|
|
@ -262,12 +262,10 @@ impl NodeClient {
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let pipe_name = pipe_name.as_ref().to_os_string();
|
let pipe_name = pipe_name.as_ref().to_os_string();
|
||||||
|
|
||||||
let bearer = tokio::task::spawn_blocking(move || {
|
let bearer = tokio::task::spawn_blocking(move || Bearer::connect_named_pipe(pipe_name))
|
||||||
Bearer::connect_named_pipe(pipe_name)
|
.await
|
||||||
})
|
.expect("can't join tokio thread")
|
||||||
.await
|
.map_err(Error::ConnectFailure)?;
|
||||||
.expect("can't join tokio thread")
|
|
||||||
.map_err(Error::ConnectFailure)?;
|
|
||||||
|
|
||||||
let mut client = Self::new(bearer);
|
let mut client = Self::new(bearer);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,5 @@ mod protocol;
|
||||||
mod server;
|
mod server;
|
||||||
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
pub use server::*;
|
pub use server::*;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,5 @@ mod server;
|
||||||
|
|
||||||
pub use buffer::*;
|
pub use buffer::*;
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
pub use server::*;
|
pub use server::*;
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,4 @@ mod codec;
|
||||||
mod protocol;
|
mod protocol;
|
||||||
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,5 @@ mod server;
|
||||||
pub mod queries_v16;
|
pub mod queries_v16;
|
||||||
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
pub use server::*;
|
pub use server::*;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
|
|
||||||
mod client;
|
mod client;
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,4 @@ mod codec;
|
||||||
mod protocol;
|
mod protocol;
|
||||||
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,5 @@ mod protocol;
|
||||||
mod server;
|
mod server;
|
||||||
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
pub use codec::*;
|
|
||||||
pub use protocol::*;
|
pub use protocol::*;
|
||||||
pub use server::*;
|
pub use server::*;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::collections::HashMap;
|
||||||
use byteorder::{ByteOrder, NetworkEndian};
|
use byteorder::{ByteOrder, NetworkEndian};
|
||||||
use pallas_codec::{minicbor, Fragment};
|
use pallas_codec::{minicbor, Fragment};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt, ReadHalf, WriteHalf};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
use tokio::time::Instant;
|
use tokio::time::Instant;
|
||||||
use tokio::{select, sync::mpsc::error::SendError};
|
use tokio::{select, sync::mpsc::error::SendError};
|
||||||
|
|
@ -21,6 +21,9 @@ use tokio::net as unix;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use tokio::net::windows::named_pipe::NamedPipeClient;
|
use tokio::net::windows::named_pipe::NamedPipeClient;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
use tokio::io::{ReadHalf, WriteHalf};
|
||||||
|
|
||||||
const HEADER_LEN: usize = 8;
|
const HEADER_LEN: usize = 8;
|
||||||
|
|
||||||
pub type Timestamp = u32;
|
pub type Timestamp = u32;
|
||||||
|
|
@ -126,9 +129,8 @@ impl Bearer {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn connect_named_pipe(pipe_name: impl AsRef<std::ffi::OsStr>) ->
|
pub fn connect_named_pipe(pipe_name: impl AsRef<std::ffi::OsStr>) -> IOResult<Self> {
|
||||||
IOResult<Self> { let client =
|
let client = tokio::net::windows::named_pipe::ClientOptions::new().open(&pipe_name)?;
|
||||||
tokio::net::windows::named_pipe::ClientOptions::new().open(&pipe_name)?;
|
|
||||||
Ok(Self::NamedPipe(client))
|
Ok(Self::NamedPipe(client))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,7 +176,7 @@ impl BearerReadHalf {
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
BearerReadHalf::Unix(x) => x.read_exact(buf).await,
|
BearerReadHalf::Unix(x) => x.read_exact(buf).await,
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
BearerReadHalf::NamedPipe(x) => x.read_exact(buf).await,
|
BearerReadHalf::NamedPipe(x) => x.read_exact(buf).await,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use ed25519_bip32;
|
|
||||||
use pallas_crypto::key::ed25519::{PublicKey, SecretKey, SecretKeyExtended, Signature};
|
use pallas_crypto::key::ed25519::{PublicKey, SecretKey, SecretKeyExtended, Signature};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|
@ -40,6 +39,7 @@ pub enum PrivateKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrivateKey {
|
impl PrivateKey {
|
||||||
|
#[allow(clippy::len_without_is_empty)]
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::Normal(_) => SecretKey::SIZE,
|
Self::Normal(_) => SecretKey::SIZE,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue