Skip to content

Commit

Permalink
Improve storage monitor API
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jan 10, 2024
1 parent 01ea45c commit b60f5d3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion polkadot/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ where

sc_storage_monitor::StorageMonitorService::try_spawn(
cli.storage_monitor,
database_source,
database_source.path(),
&task_manager.spawn_essential_handle(),
)?;

Expand Down
3 changes: 1 addition & 2 deletions substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,13 +769,12 @@ pub fn new_full_base(
/// Builds a new service for a full client.
pub fn new_full(config: Configuration, cli: Cli) -> Result<TaskManager, ServiceError> {
let mixnet_config = cli.mixnet_params.config(config.role.is_authority());
let database_source = config.database.clone();
let task_manager = new_full_base(config, mixnet_config, cli.no_hardware_benchmarks, |_, _| ())
.map(|NewFullBase { task_manager, .. }| task_manager)?;

sc_storage_monitor::StorageMonitorService::try_spawn(
cli.storage_monitor,
database_source,
config.database.path(),
&task_manager.spawn_essential_handle(),
)
.map_err(|e| ServiceError::Application(e.into()))?;
Expand Down
1 change: 0 additions & 1 deletion substrate/client/storage-monitor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ workspace = true
clap = { version = "4.4.14", features = ["derive", "string"] }
log = "0.4.17"
fs4 = "0.7.0"
sc-client-db = { path = "../db", default-features = false }
sp-core = { path = "../../primitives/core" }
tokio = "1.22.0"
thiserror = "1.0.48"
10 changes: 5 additions & 5 deletions substrate/client/storage-monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use clap::Args;
use sc_client_db::DatabaseSource;
use sp_core::traits::SpawnEssentialNamed;
use std::{
io,
Expand Down Expand Up @@ -70,10 +69,10 @@ impl StorageMonitorService {
/// Creates new StorageMonitorService for given client config
pub fn try_spawn(
parameters: StorageMonitorParams,
database: DatabaseSource,
path: Option<&Path>,
spawner: &impl SpawnEssentialNamed,
) -> Result<()> {
Ok(match (parameters.threshold, database.path()) {
Ok(match (parameters.threshold, path) {
(0, _) => {
log::info!(
target: LOG_TARGET,
Expand All @@ -89,10 +88,11 @@ impl StorageMonitorService {
(threshold, Some(path)) => {
log::debug!(
target: LOG_TARGET,
"Initializing StorageMonitorService for db path: {path:?}",
"Initializing StorageMonitorService for db path: {}",
path.display()
);

Self::check_free_space(&path, threshold)?;
Self::check_free_space(path, threshold)?;

let storage_monitor_service = StorageMonitorService {
path: path.to_path_buf(),
Expand Down

0 comments on commit b60f5d3

Please sign in to comment.