Skip to content
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
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/floresta-chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ bitcoin = { version = "0.32", features = [
"serde",
], default-features = false }
spin = "0.9.8"
core2 = { version = "0.4.0", default-features = false }
floresta-common = { path = "../floresta-common", default-features = false, features = ["std"] }
bitcoinconsensus = { version = "0.106.0", optional = true, default-features = false }
metrics = { path = "../../metrics", optional = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/floresta-chain/src/pruned_utreexo/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
//! Each error type implements `Display` and `Debug` for error reporting.

use core::fmt::Debug;
extern crate alloc;

use bitcoin::blockdata::script;
use bitcoin::Network;
use bitcoin::OutPoint;
use bitcoin::Txid;
use floresta_common::impl_error_from;
use floresta_common::prelude::*;

use crate::prelude::*;
use crate::pruned_utreexo::chain_state_builder::BlockchainBuilderError;

pub trait DatabaseError: Debug + Send + Sync + 'static {}
Expand Down Expand Up @@ -180,4 +181,4 @@ impl Display for BlockchainError {
}

impl DatabaseError for kv::Error {}
impl core2::error::Error for BlockchainError {}
impl Error for BlockchainError {}
2 changes: 1 addition & 1 deletion crates/floresta-chain/src/pruned_utreexo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use crate::UtreexoBlock;
/// This trait is the main interface between our blockchain backend and other services.
/// It'll be useful for transitioning from rpc to a p2p based node
pub trait BlockchainInterface {
type Error: core2::error::Error + Send + Sync + 'static;
type Error: Error + Send + Sync + 'static;
/// Returns the block with a given height in our current tip.
fn get_block_hash(&self, height: u32) -> Result<bitcoin::BlockHash, Self::Error>;
/// Returns a bitcoin [Transaction] given it's txid.
Expand Down
9 changes: 9 additions & 0 deletions crates/floresta-common/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// A no-std implementation of the `Error` trait for floresta
use crate::prelude::fmt::Debug;
use crate::prelude::Display;

/// `Error` is a trait representing the basic expectations for error values,
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
/// themselves through the [`Display`] and [`Debug`] traits. This is a simplified implementation of
/// the trait, used inside floresta, in case of a no-std environment.
pub trait Error: Debug + Display {}
11 changes: 7 additions & 4 deletions crates/floresta-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use miniscript::Descriptor;
use miniscript::DescriptorPublicKey;
use sha2::Digest;

#[cfg(not(feature = "std"))]
mod error;
pub mod macros;
pub mod spsc;

Expand Down Expand Up @@ -119,12 +121,13 @@ pub mod prelude {
pub use core::str;
pub use core::str::FromStr;

pub use core2::error::Error;
pub use core2::io::Error as ioError;
pub use core2::io::Read;
pub use core2::io::Write;
pub use bitcoin::io::Error as ioError;
pub use bitcoin::io::Read;
pub use bitcoin::io::Write;
pub use hashbrown::HashMap;
pub use hashbrown::HashSet;

pub use crate::error::Error;
}
#[cfg(feature = "std")]
pub mod prelude {
Expand Down
1 change: 0 additions & 1 deletion crates/floresta-electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ serde_json = "1.0"
futures = "0.3.4"
bitcoin = { version = "0.32", features = ["serde", "std", "bitcoinconsensus"] }
thiserror = "1.0"
core2 = { version = "0.4.0", default-features = false }

[dev-dependencies]
rand = "0.8.5"
Expand Down
5 changes: 4 additions & 1 deletion crates/floresta-electrum/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ use thiserror::Error;
pub enum Error {
#[error("Invalid params passed in")]
InvalidParams,

#[error("Invalid json string {0}")]
Parsing(#[from] serde_json::Error),

#[error("Blockchain error")]
Blockchain(Box<dyn core2::error::Error + Send + 'static>),
Blockchain(Box<dyn floresta_common::prelude::Error + Send + 'static>),

#[error("IO error")]
Io(#[from] std::io::Error),
}
Loading