mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make stages types no-std (#14334)
This commit is contained in:
@ -404,7 +404,7 @@ reth-rpc-server-types = { path = "crates/rpc/rpc-server-types" }
|
||||
reth-rpc-types-compat = { path = "crates/rpc/rpc-types-compat" }
|
||||
reth-stages = { path = "crates/stages/stages" }
|
||||
reth-stages-api = { path = "crates/stages/api" }
|
||||
reth-stages-types = { path = "crates/stages/types" }
|
||||
reth-stages-types = { path = "crates/stages/types", default-features = false }
|
||||
reth-static-file = { path = "crates/static-file/static-file" }
|
||||
reth-static-file-types = { path = "crates/static-file/types" }
|
||||
reth-storage-api = { path = "crates/storage/storage-api" }
|
||||
|
||||
@ -34,6 +34,13 @@ rand.workspace = true
|
||||
bytes.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"alloy-primitives/std",
|
||||
"bytes?/std",
|
||||
"reth-trie-common/std",
|
||||
"serde?/std",
|
||||
]
|
||||
reth-codec = [
|
||||
"dep:reth-codecs",
|
||||
"dep:bytes",
|
||||
@ -41,11 +48,13 @@ reth-codec = [
|
||||
"reth-trie-common/reth-codec",
|
||||
]
|
||||
test-utils = [
|
||||
"dep:arbitrary",
|
||||
"arbitrary",
|
||||
"reth-codecs?/test-utils",
|
||||
"reth-trie-common/test-utils",
|
||||
]
|
||||
arbitrary = [
|
||||
"std",
|
||||
"dep:arbitrary",
|
||||
"alloy-primitives/arbitrary",
|
||||
"reth-codecs?/arbitrary",
|
||||
"reth-trie-common/arbitrary",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use super::StageId;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::{format, string::String, vec::Vec};
|
||||
use alloy_primitives::{Address, BlockNumber, B256};
|
||||
use core::ops::RangeInclusive;
|
||||
use reth_trie_common::{hash_builder::HashBuilderState, StoredSubNode};
|
||||
@ -170,6 +170,11 @@ impl EntitiesCheckpoint {
|
||||
let percentage = 100.0 * self.processed as f64 / self.total as f64;
|
||||
|
||||
// Truncate to 2 decimal places, rounding down so that 99.999% becomes 99.99% and not 100%.
|
||||
#[cfg(not(feature = "std"))]
|
||||
{
|
||||
Some(format!("{:.2}%", (percentage * 100.0) / 100.0))
|
||||
}
|
||||
#[cfg(feature = "std")]
|
||||
Some(format!("{:.2}%", (percentage * 100.0).floor() / 100.0))
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,8 +97,8 @@ impl StageId {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StageId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl core::fmt::Display for StageId {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
write!(f, "{}", self.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
)]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
@ -68,7 +69,7 @@ impl From<BlockHash> for PipelineTarget {
|
||||
}
|
||||
|
||||
impl core::fmt::Display for PipelineTarget {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
match self {
|
||||
Self::Sync(block) => {
|
||||
write!(f, "Sync({block})")
|
||||
|
||||
@ -46,4 +46,5 @@ std = [
|
||||
"reth-primitives/std",
|
||||
"reth-primitives-traits/std",
|
||||
"revm/std",
|
||||
"reth-stages-types/std",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user