mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-04 15:35:18 +00:00
Compare commits
5 Commits
9b2c3a6c7c
...
e87ac3e54d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e87ac3e54d | ||
![]() |
d43a616b56 | ||
![]() |
14226dbddc | ||
![]() |
608195f536 | ||
![]() |
d230105b98 |
@ -34,7 +34,7 @@ pub struct AppendMerkleTree<E: HashElement, A: Algorithm<E>> {
|
|||||||
/// `revert_to` can reset the state correctly when needed.
|
/// `revert_to` can reset the state correctly when needed.
|
||||||
min_depth: Option<usize>,
|
min_depth: Option<usize>,
|
||||||
/// Used to compute the correct padding hash.
|
/// Used to compute the correct padding hash.
|
||||||
/// 0 for `pora_chunk_merkle` and 10 for not-first `last_chunk_merkle`.
|
/// 0 for `first_chunk_merkle` and 10 for not-first `last_chunk_merkle`.
|
||||||
leaf_height: usize,
|
leaf_height: usize,
|
||||||
_a: PhantomData<A>,
|
_a: PhantomData<A>,
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ where
|
|||||||
self.insert_at(key, self.default_entry_timeout);
|
self.insert_at(key, self.default_entry_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts an entry that will expire at a given instant. If the entry already exists, the
|
/// Inserts an entry that will expire at a given duration. If the entry already exists, the
|
||||||
/// timeout is updated.
|
/// timeout is updated.
|
||||||
pub fn insert_at(&mut self, key: K, entry_duration: Duration) {
|
pub fn insert_at(&mut self, key: K, entry_duration: Duration) {
|
||||||
if self.contains(&key) {
|
if self.contains(&key) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
//!
|
//!
|
||||||
//! - `Histogram`: used with `start_timer(..)` and `stop_timer(..)` to record durations (e.g.,
|
//! - `Histogram`: used with `start_timer(..)` and `stop_timer(..)` to record durations (e.g.,
|
||||||
//! block processing time).
|
//! block processing time).
|
||||||
//! - `IncCounter`: used to represent an ideally ever-growing, never-shrinking integer (e.g.,
|
//! - `IntCounter`: used to represent an ideally ever-growing, never-shrinking integer (e.g.,
|
||||||
//! number of block processing requests).
|
//! number of block processing requests).
|
||||||
//! - `IntGauge`: used to represent a varying integer (e.g., number of attestations per block).
|
//! - `IntGauge`: used to represent a varying integer (e.g., number of attestations per block).
|
||||||
//!
|
//!
|
||||||
@ -78,7 +78,7 @@ pub fn try_create_int_counter(name: &str, help: &str) -> Result<IntCounter> {
|
|||||||
Ok(counter)
|
Ok(counter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to create an `IntGauge`, returning `Err` if the registry does not accept the counter
|
/// Attempts to create an `IntGauge`, returning `Err` if the registry does not accept the gauge
|
||||||
/// (potentially due to naming conflict).
|
/// (potentially due to naming conflict).
|
||||||
pub fn try_create_int_gauge(name: &str, help: &str) -> Result<IntGauge> {
|
pub fn try_create_int_gauge(name: &str, help: &str) -> Result<IntGauge> {
|
||||||
let opts = Opts::new(name, help);
|
let opts = Opts::new(name, help);
|
||||||
@ -87,7 +87,7 @@ pub fn try_create_int_gauge(name: &str, help: &str) -> Result<IntGauge> {
|
|||||||
Ok(gauge)
|
Ok(gauge)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to create a `Gauge`, returning `Err` if the registry does not accept the counter
|
/// Attempts to create a `Gauge`, returning `Err` if the registry does not accept the gauge
|
||||||
/// (potentially due to naming conflict).
|
/// (potentially due to naming conflict).
|
||||||
pub fn try_create_float_gauge(name: &str, help: &str) -> Result<Gauge> {
|
pub fn try_create_float_gauge(name: &str, help: &str) -> Result<Gauge> {
|
||||||
let opts = Opts::new(name, help);
|
let opts = Opts::new(name, help);
|
||||||
@ -96,7 +96,7 @@ pub fn try_create_float_gauge(name: &str, help: &str) -> Result<Gauge> {
|
|||||||
Ok(gauge)
|
Ok(gauge)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to create a `Histogram`, returning `Err` if the registry does not accept the counter
|
/// Attempts to create a `Histogram`, returning `Err` if the registry does not accept the histogram
|
||||||
/// (potentially due to naming conflict).
|
/// (potentially due to naming conflict).
|
||||||
pub fn try_create_histogram(name: &str, help: &str) -> Result<Histogram> {
|
pub fn try_create_histogram(name: &str, help: &str) -> Result<Histogram> {
|
||||||
let opts = HistogramOpts::new(name, help);
|
let opts = HistogramOpts::new(name, help);
|
||||||
@ -105,7 +105,7 @@ pub fn try_create_histogram(name: &str, help: &str) -> Result<Histogram> {
|
|||||||
Ok(histogram)
|
Ok(histogram)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to create a `HistogramVec`, returning `Err` if the registry does not accept the counter
|
/// Attempts to create a `HistogramVec`, returning `Err` if the registry does not accept the histogram
|
||||||
/// (potentially due to naming conflict).
|
/// (potentially due to naming conflict).
|
||||||
pub fn try_create_histogram_vec(
|
pub fn try_create_histogram_vec(
|
||||||
name: &str,
|
name: &str,
|
||||||
@ -144,7 +144,7 @@ pub fn try_create_float_gauge_vec(
|
|||||||
Ok(counter_vec)
|
Ok(counter_vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to create a `IntCounterVec`, returning `Err` if the registry does not accept the gauge
|
/// Attempts to create a `IntCounterVec`, returning `Err` if the registry does not accept the counter
|
||||||
/// (potentially due to naming conflict).
|
/// (potentially due to naming conflict).
|
||||||
pub fn try_create_int_counter_vec(
|
pub fn try_create_int_counter_vec(
|
||||||
name: &str,
|
name: &str,
|
||||||
|
@ -276,7 +276,7 @@ impl Pruner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_shard_config(store: &Store) -> Result<Option<ShardConfig>> {
|
pub async fn get_shard_config(store: &Store) -> Result<Option<ShardConfig>> {
|
||||||
store
|
store
|
||||||
.get_config_decoded(&SHARD_CONFIG_KEY, DATA_DB_KEY)
|
.get_config_decoded(&SHARD_CONFIG_KEY, DATA_DB_KEY)
|
||||||
.await
|
.await
|
||||||
|
@ -7,7 +7,7 @@ use network::{
|
|||||||
self, new_network_channel, Keypair, NetworkConfig, NetworkGlobals, NetworkReceiver,
|
self, new_network_channel, Keypair, NetworkConfig, NetworkGlobals, NetworkReceiver,
|
||||||
NetworkSender, RequestId, Service as LibP2PService,
|
NetworkSender, RequestId, Service as LibP2PService,
|
||||||
};
|
};
|
||||||
use pruner::{Pruner, PrunerConfig, PrunerMessage};
|
use pruner::{get_shard_config, Pruner, PrunerConfig, PrunerMessage};
|
||||||
use router::RouterService;
|
use router::RouterService;
|
||||||
use rpc::RPCConfig;
|
use rpc::RPCConfig;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -203,7 +203,7 @@ impl ClientBuilder {
|
|||||||
if let Some(config) = config {
|
if let Some(config) = config {
|
||||||
let executor = require!("miner", self, runtime_context).clone().executor;
|
let executor = require!("miner", self, runtime_context).clone().executor;
|
||||||
let network_send = require!("miner", self, network).send.clone();
|
let network_send = require!("miner", self, network).send.clone();
|
||||||
let store = self.async_store.as_ref().unwrap().clone();
|
let store = require!("miner", self, async_store).clone();
|
||||||
|
|
||||||
let send = MineService::spawn(executor, network_send, config, store).await?;
|
let send = MineService::spawn(executor, network_send, config, store).await?;
|
||||||
self.miner = Some(MinerComponents { send });
|
self.miner = Some(MinerComponents { send });
|
||||||
@ -225,7 +225,11 @@ impl ClientBuilder {
|
|||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn with_shard(self, config: ShardConfig) -> Result<Self, String> {
|
pub async fn with_shard(self, mut config: ShardConfig) -> Result<Self, String> {
|
||||||
|
let store = require!("shard", self, async_store).clone();
|
||||||
|
if let Some(stored_config) = get_shard_config(store.as_ref()).await.unwrap_or(None) {
|
||||||
|
config = stored_config;
|
||||||
|
}
|
||||||
self.async_store
|
self.async_store
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -23,6 +23,8 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
|
|||||||
ClientBuilder::default()
|
ClientBuilder::default()
|
||||||
.with_runtime_context(context)
|
.with_runtime_context(context)
|
||||||
.with_rocksdb_store(&storage_config)?
|
.with_rocksdb_store(&storage_config)?
|
||||||
|
.with_shard(shard_config)
|
||||||
|
.await?
|
||||||
.with_log_sync(log_sync_config)
|
.with_log_sync(log_sync_config)
|
||||||
.await?
|
.await?
|
||||||
.with_file_location_cache(config.file_location_cache)
|
.with_file_location_cache(config.file_location_cache)
|
||||||
@ -34,8 +36,6 @@ async fn start_node(context: RuntimeContext, config: ZgsConfig) -> Result<Client
|
|||||||
.await?
|
.await?
|
||||||
.with_miner(miner_config)
|
.with_miner(miner_config)
|
||||||
.await?
|
.await?
|
||||||
.with_shard(shard_config)
|
|
||||||
.await?
|
|
||||||
.with_pruner(pruner_config)
|
.with_pruner(pruner_config)
|
||||||
.await?
|
.await?
|
||||||
.with_rpc(config.rpc)
|
.with_rpc(config.rpc)
|
||||||
|
@ -1157,6 +1157,7 @@ impl LogManager {
|
|||||||
.get_tx_by_seq_number(from_tx_seq)?
|
.get_tx_by_seq_number(from_tx_seq)?
|
||||||
.ok_or_else(|| anyhow!("from tx missing"))?;
|
.ok_or_else(|| anyhow!("from tx missing"))?;
|
||||||
let mut to_tx_offset_list = Vec::with_capacity(to_tx_seq_list.len());
|
let mut to_tx_offset_list = Vec::with_capacity(to_tx_seq_list.len());
|
||||||
|
|
||||||
for seq in to_tx_seq_list {
|
for seq in to_tx_seq_list {
|
||||||
// No need to copy data for completed tx.
|
// No need to copy data for completed tx.
|
||||||
if self.check_tx_completed(seq)? {
|
if self.check_tx_completed(seq)? {
|
||||||
|
Loading…
Reference in New Issue
Block a user