Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7fbed1b
Initial commit
cecton Jun 2, 2020
aa518e4
Add a feature to create automatically a temporary directory for base …
cecton Jun 2, 2020
5338633
doc fix and todos
cecton Jun 2, 2020
baf6ad2
use parking_lot instead
cecton Jun 3, 2020
179dda3
use refcell instead since we stay in the main thread
cecton Jun 3, 2020
2aea88f
remove Clone derives
cecton Jun 3, 2020
b6358e8
add test
cecton Jun 3, 2020
f81522d
solving dependency issue
cecton Jun 3, 2020
55ed555
clarifying doc
cecton Jun 3, 2020
cfc6fa4
conflict argument with base-path
cecton Jun 3, 2020
5a5c546
WIP
cecton Jun 4, 2020
bf1da7e
Merge commit f028a509789289a34c468f42b4361c49279893f2 (no conflict)
cecton Jun 4, 2020
68dfe89
revert dep deletion
cecton Jun 4, 2020
898dcd6
fixing test and making base_path optional
cecton Jun 4, 2020
d26da87
hold basepath while the service is running
cecton Jun 4, 2020
9c6f71a
fixes
cecton Jun 4, 2020
9e989de
Update client/cli/src/params/shared_params.rs
cecton Jun 5, 2020
c811cb6
Update client/service/Cargo.toml
cecton Jun 5, 2020
65cb074
Update client/cli/src/commands/mod.rs
cecton Jun 5, 2020
fdb3f20
Update client/service/src/config.rs
cecton Jun 5, 2020
39bc022
WIP
cecton Jun 5, 2020
cb140b6
improve doc
cecton Jun 8, 2020
ca42803
Merge commit 252b146b43e3877aefae6afd5c9a9e6093c5d7a9 (no conflict)
cecton Jun 8, 2020
468f16a
Merge commit 9ce077465ac46a93ebaced4b47863952b3d63d33 (conflicts)
cecton Jun 8, 2020
49cfe00
Merge commit d68cfd7cd5c64cb0965b49d9868aff02849e077c (no conflict)
cecton Jun 8, 2020
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
Prev Previous commit
Next Next commit
use refcell instead since we stay in the main thread
  • Loading branch information
cecton committed Jun 3, 2020
commit 179dda32e60a539501edc9405e8d04ad14a03d9e
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.

1 change: 0 additions & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ sc-tracing = { version = "2.0.0-rc2", path = "../tracing" }
chrono = "0.4.10"
parity-util-mem = { version = "0.6.1", default-features = false, features = ["primitive-types"] }
tempfile = "3.1.0"
parking_lot = "0.10.2"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
rpassword = "4.0.1"
Expand Down
11 changes: 6 additions & 5 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ use crate::params::OffchainWorkerParams;
use crate::params::SharedParams;
use crate::params::TransactionPoolParams;
use crate::CliConfiguration;
use parking_lot::Mutex;
use regex::Regex;
use sc_service::{
config::{MultiaddrWithPeerId, PrometheusConfig, TransactionPoolOptions},
ChainSpec, Role,
};
use sc_telemetry::TelemetryEndpoints;
use std::{
cell::RefCell,
net::{IpAddr, Ipv4Addr, SocketAddr},
path::PathBuf,
};
Expand Down Expand Up @@ -267,7 +267,7 @@ pub struct RunCmd {
pub tmp: bool,

#[structopt(skip)]
temp_base_path: Mutex<Option<TempDir>>,
temp_base_path: RefCell<Option<TempDir>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This is a really bad hack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part you don't like exactly? (so I can find another way)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having the temp base path as parameter here.

We could create some custom type that we return in base_path

Copy link
Contributor Author

@cecton cecton Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok done! Now the TempDir is hold in the configuration object instead of the SubstrateCli object, then it's move to the service and dropped with it. Also the core of the feature itself has moved from sc-cli to sc-service.

}

impl RunCmd {
Expand Down Expand Up @@ -467,10 +467,11 @@ impl CliConfiguration for RunCmd {

fn base_path(&self) -> Result<Option<PathBuf>> {
Ok(if self.tmp {
*self.temp_base_path.lock() =
Some(tempfile::Builder::new().prefix("substrate").tempdir()?);
let tmp = tempfile::Builder::new().prefix("substrate").tempdir()?;
let path = tmp.path().into();
*self.temp_base_path.borrow_mut() = Some(tmp);

self.temp_base_path.lock().as_ref().map(|x| x.path().into())
Some(path)
} else {
self.shared_params().base_path()
})
Expand Down