mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
State pruning (#216)
* Started work on state db * Updated for a new hash type * Pruning and tests * Generalize on the block hash/key type * Integrate with the client backend * Merge w master * CLI options * Updated for light client refactoring * Used IntoIterator * Fixed invalid input hadling
This commit is contained in:
committed by
Gav Wood
parent
de8dedd878
commit
a53b47e11a
@@ -75,6 +75,11 @@ args:
|
|||||||
value_name: CHAIN_SPEC
|
value_name: CHAIN_SPEC
|
||||||
help: Specify the chain specification (one of dev, local or poc-2)
|
help: Specify the chain specification (one of dev, local or poc-2)
|
||||||
takes_value: true
|
takes_value: true
|
||||||
|
- pruning:
|
||||||
|
long: pruning
|
||||||
|
value_name: PRUNING_MODE
|
||||||
|
help: Specify the pruning mode. (a number of blocks to keep or "archive"). Default is 256.
|
||||||
|
takes_value: true
|
||||||
- name:
|
- name:
|
||||||
long: name
|
long: name
|
||||||
value_name: NAME
|
value_name: NAME
|
||||||
|
|||||||
@@ -28,5 +28,10 @@ error_chain! {
|
|||||||
Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"];
|
Client(client::error::Error, client::error::ErrorKind) #[doc="Client error"];
|
||||||
}
|
}
|
||||||
errors {
|
errors {
|
||||||
|
/// Input error.
|
||||||
|
Input(m: String) {
|
||||||
|
description("Invalid input"),
|
||||||
|
display("{}", m),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ use polkadot_primitives::Block;
|
|||||||
use futures::sync::mpsc;
|
use futures::sync::mpsc;
|
||||||
use futures::{Sink, Future, Stream};
|
use futures::{Sink, Future, Stream};
|
||||||
use tokio_core::reactor;
|
use tokio_core::reactor;
|
||||||
|
use service::PruningMode;
|
||||||
|
|
||||||
const DEFAULT_TELEMETRY_URL: &str = "ws://telemetry.polkadot.io:1024";
|
const DEFAULT_TELEMETRY_URL: &str = "ws://telemetry.polkadot.io:1024";
|
||||||
|
|
||||||
@@ -189,6 +190,12 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
|
|||||||
.into();
|
.into();
|
||||||
|
|
||||||
config.database_path = db_path(&base_path).to_string_lossy().into();
|
config.database_path = db_path(&base_path).to_string_lossy().into();
|
||||||
|
config.pruning = match matches.value_of("pruning") {
|
||||||
|
Some("archive") => PruningMode::ArchiveAll,
|
||||||
|
None => PruningMode::keep_blocks(256),
|
||||||
|
Some(s) => PruningMode::keep_blocks(s.parse()
|
||||||
|
.map_err(|_| error::ErrorKind::Input("Invalid pruning mode specified".to_owned()))?),
|
||||||
|
};
|
||||||
|
|
||||||
let (mut genesis_storage, boot_nodes) = PresetConfig::from_spec(chain_spec)
|
let (mut genesis_storage, boot_nodes) = PresetConfig::from_spec(chain_spec)
|
||||||
.map(PresetConfig::deconstruct)
|
.map(PresetConfig::deconstruct)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ use transaction_pool;
|
|||||||
use runtime_primitives::MakeStorage;
|
use runtime_primitives::MakeStorage;
|
||||||
pub use network::Role;
|
pub use network::Role;
|
||||||
pub use network::NetworkConfiguration;
|
pub use network::NetworkConfiguration;
|
||||||
|
pub use client_db::PruningMode;
|
||||||
|
|
||||||
/// Service configuration.
|
/// Service configuration.
|
||||||
pub struct Configuration {
|
pub struct Configuration {
|
||||||
@@ -33,6 +34,8 @@ pub struct Configuration {
|
|||||||
pub keystore_path: String,
|
pub keystore_path: String,
|
||||||
/// Path to the database.
|
/// Path to the database.
|
||||||
pub database_path: String,
|
pub database_path: String,
|
||||||
|
/// Pruning settings.
|
||||||
|
pub pruning: PruningMode,
|
||||||
/// Additional key seeds.
|
/// Additional key seeds.
|
||||||
pub keys: Vec<String>,
|
pub keys: Vec<String>,
|
||||||
/// The name of the chain.
|
/// The name of the chain.
|
||||||
@@ -58,6 +61,7 @@ impl Default for Configuration {
|
|||||||
genesis_storage: Box::new(Default::default),
|
genesis_storage: Box::new(Default::default),
|
||||||
telemetry: Default::default(),
|
telemetry: Default::default(),
|
||||||
name: "Anonymous".into(),
|
name: "Anonymous".into(),
|
||||||
|
pruning: PruningMode::ArchiveAll,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ use exit_future::Signal;
|
|||||||
|
|
||||||
pub use self::error::{ErrorKind, Error};
|
pub use self::error::{ErrorKind, Error};
|
||||||
pub use self::components::{Components, FullComponents, LightComponents};
|
pub use self::components::{Components, FullComponents, LightComponents};
|
||||||
pub use config::{Configuration, Role};
|
pub use config::{Configuration, Role, PruningMode};
|
||||||
|
|
||||||
/// Polkadot service.
|
/// Polkadot service.
|
||||||
pub struct Service<Components: components::Components> {
|
pub struct Service<Components: components::Components> {
|
||||||
@@ -118,6 +118,7 @@ impl<Components> Service<Components>
|
|||||||
let db_settings = client_db::DatabaseSettings {
|
let db_settings = client_db::DatabaseSettings {
|
||||||
cache_size: None,
|
cache_size: None,
|
||||||
path: config.database_path.into(),
|
path: config.database_path.into(),
|
||||||
|
pruning: config.pruning,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (client, on_demand) = components.build_client(db_settings, executor, config.genesis_storage)?;
|
let (client, on_demand) = components.build_client(db_settings, executor, config.genesis_storage)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user