mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
Expand remote keystore interface to allow for hybrid mode (#7628)
* update to latest master * updates on docs, license, meta * hide ssrs behind feature flag * implement remaining functions on the server * sign server line length fix * fix tests * fixup in-memory-keystore * adding failsafe * skipping ecdsa test for now * remote keystore param * remote sign urls made available * integrating keystore remotes features * don't forget the dependency * remove old cruft * reset local keystore * applying suggestions * Switch to single remote, minor grumbles * minor grumbles, docs
This commit is contained in:
committed by
GitHub
parent
7a43cca875
commit
5ce8c33368
@@ -65,7 +65,7 @@ impl InsertCmd {
|
||||
.ok_or_else(|| Error::MissingBasePath)?;
|
||||
|
||||
let (keystore, public) = match self.keystore_params.keystore_config(base_path)? {
|
||||
KeystoreConfig::Path { path, password } => {
|
||||
(_, KeystoreConfig::Path { path, password }) => {
|
||||
let public = with_crypto_scheme!(
|
||||
self.crypto_scheme.scheme,
|
||||
to_vec(&suri, password.clone())
|
||||
|
||||
@@ -188,10 +188,10 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
///
|
||||
/// Bu default this is retrieved from `KeystoreParams` if it is available. Otherwise it uses
|
||||
/// `KeystoreConfig::InMemory`.
|
||||
fn keystore_config(&self, base_path: &PathBuf) -> Result<KeystoreConfig> {
|
||||
fn keystore_config(&self, base_path: &PathBuf) -> Result<(Option<String>, KeystoreConfig)> {
|
||||
self.keystore_params()
|
||||
.map(|x| x.keystore_config(base_path))
|
||||
.unwrap_or(Ok(KeystoreConfig::InMemory))
|
||||
.unwrap_or_else(|| Ok((None, KeystoreConfig::InMemory)))
|
||||
}
|
||||
|
||||
/// Get the database cache size.
|
||||
@@ -471,6 +471,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
let role = self.role(is_dev)?;
|
||||
let max_runtime_instances = self.max_runtime_instances()?.unwrap_or(8);
|
||||
let is_validator = role.is_network_authority();
|
||||
let (keystore_remote, keystore) = self.keystore_config(&config_dir)?;
|
||||
|
||||
let unsafe_pruning = self
|
||||
.import_params()
|
||||
@@ -491,7 +492,8 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
|
||||
node_key,
|
||||
DCV::p2p_listen_port(),
|
||||
)?,
|
||||
keystore: self.keystore_config(&config_dir)?,
|
||||
keystore_remote,
|
||||
keystore,
|
||||
database: self.database_config(&config_dir, database_cache_size, database)?,
|
||||
state_cache_size: self.state_cache_size()?,
|
||||
state_cache_child_ratio: self.state_cache_child_ratio()?,
|
||||
|
||||
@@ -30,6 +30,9 @@ const DEFAULT_KEYSTORE_CONFIG_PATH: &'static str = "keystore";
|
||||
/// Parameters of the keystore
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct KeystoreParams {
|
||||
/// Specify custom URIs to connect to for keystore-services
|
||||
#[structopt(long = "keystore-uri")]
|
||||
pub keystore_uri: Option<String>,
|
||||
/// Specify custom keystore path.
|
||||
#[structopt(long = "keystore-path", value_name = "PATH", parse(from_os_str))]
|
||||
pub keystore_path: Option<PathBuf>,
|
||||
@@ -67,7 +70,9 @@ pub fn secret_string_from_str(s: &str) -> std::result::Result<SecretString, Stri
|
||||
|
||||
impl KeystoreParams {
|
||||
/// Get the keystore configuration for the parameters
|
||||
pub fn keystore_config(&self, base_path: &PathBuf) -> Result<KeystoreConfig> {
|
||||
/// returns a vector of remote-urls and the local Keystore configuration
|
||||
pub fn keystore_config(&self, base_path: &PathBuf) -> Result<(Option<String>, KeystoreConfig)> {
|
||||
|
||||
let password = if self.password_interactive {
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
{
|
||||
@@ -89,7 +94,7 @@ impl KeystoreParams {
|
||||
.clone()
|
||||
.unwrap_or_else(|| base_path.join(DEFAULT_KEYSTORE_CONFIG_PATH));
|
||||
|
||||
Ok(KeystoreConfig::Path { path, password })
|
||||
Ok((self.keystore_uri.clone(), KeystoreConfig::Path { path, password }))
|
||||
}
|
||||
|
||||
/// helper method to fetch password from `KeyParams` or read from stdin
|
||||
|
||||
Reference in New Issue
Block a user