chore: fix lint warnings across the board (#374)
This commit is contained in:
parent
972102aed8
commit
9200663c8d
12 changed files with 31 additions and 31 deletions
|
|
@ -5,7 +5,7 @@ use pallas::{
|
|||
miniprotocols::{
|
||||
chainsync,
|
||||
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
|
||||
// environment
|
||||
#[cfg(unix)]
|
||||
const SOCKET_PATH: &str = "/tmp/node.socket";
|
||||
const PIPE_NAME: &str = "\\\\.\\pipe\\cardano-pallas";
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::main]
|
||||
|
|
@ -107,10 +107,14 @@ 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)
|
||||
|
|
@ -118,9 +122,9 @@ async fn main() {
|
|||
)
|
||||
.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();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use pallas_network::miniprotocols::Point;
|
||||
use pallas_traverse::MultiEraBlock;
|
||||
use tap::Tap;
|
||||
use thiserror::Error;
|
||||
|
|
@ -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:?}")]
|
||||
|
|
@ -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");
|
||||
|
|
@ -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))
|
||||
|
|
@ -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() {
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ mod protocol;
|
|||
mod server;
|
||||
|
||||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
pub use server::*;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ mod server;
|
|||
|
||||
pub use buffer::*;
|
||||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
pub use server::*;
|
||||
|
|
|
|||
|
|
@ -3,5 +3,4 @@ mod codec;
|
|||
mod protocol;
|
||||
|
||||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ mod server;
|
|||
pub mod queries_v16;
|
||||
|
||||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
pub use server::*;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
|
||||
mod client;
|
||||
|
|
|
|||
|
|
@ -3,5 +3,4 @@ mod codec;
|
|||
mod protocol;
|
||||
|
||||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,5 @@ mod protocol;
|
|||
mod server;
|
||||
|
||||
pub use client::*;
|
||||
pub use codec::*;
|
||||
pub use protocol::*;
|
||||
pub use server::*;
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
@ -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;
|
||||
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use ed25519_bip32;
|
||||
use pallas_crypto::key::ed25519::{PublicKey, SecretKey, SecretKeyExtended, Signature};
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue