rustfmt staking-miner and fix typos

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch
2025-07-29 14:38:49 +03:00
parent e21ac88235
commit ce26787a11
14 changed files with 1317 additions and 130 deletions

View File

@@ -34,10 +34,7 @@ use std::str::FromStr;
use tokio::sync::oneshot;
use tracing_subscriber::EnvFilter;
use crate::{
client::Client,
opt::RuntimeVersion,
};
use crate::{client::Client, opt::RuntimeVersion};
#[derive(Debig, Clone, Parser)]
#[cfg_attr(test, derive(PartialEq))]
@@ -96,12 +93,17 @@ macro_rules! any_runtime {
#[tokio::main]
async fn main() -> Result<(), Error> {
let Opt { uri, command, prometheus_port, log } = Opt::parse();
let Opt {
uri,
command,
prometheus_port,
log,
} = Opt::parse();
let filter = EnvFilter::from_default_env().add_directive(log.parse()?);
tracing_subscriber::fmt().with_env_filter(filter).init();
let client = Client::new(&uri).await?;
let runtime_version: RuntimeVersion =
let runtime_version: RuntimeVersion =
client.rpc().state_get_runtime_version(None).await?.into();
let chain = opt::Chain::from_str(&runtime_version.spec_name)?;
let _prometheus_handle = prometheus::run(prometheus_port)
@@ -109,7 +111,9 @@ async fn main() -> Result<(), Error> {
log::info!(target: LOG_TARGET, "Connected to chain: {}", chain);
epm::update_metadata_constants(client.chain_api())?;
SHARED_CLIENT.set(client.clone()).expect("shared client only set once; qed");
SHARED_CLIENT
.set(client.clone())
.expect("shared client only set once; qed");
// Start a new tokio tasl to perform the runtime updates in the backgound.
// If this fails then the miner will be stopped and has to be re-started.
@@ -203,7 +207,7 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender<Error>) {
Err(e) => {
let _ = tx.send(e.into());
return;
},
}
};
loop {
@@ -218,10 +222,10 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender<Error>) {
Err(e) => {
let _ = tx.send(e.into());
return;
},
}
};
continue;
},
}
};
let version = update.runtime_version().spec_version;
@@ -233,10 +237,10 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender<Error>) {
}
prometheus::on_runtime_upgrade();
log::info!(target: LOG_TARGET, "upgrade to version: {} successful", version);
},
}
Err(e) => {
log::debug!(target: LOG_TARGET, "upgrade to version: {} failed: {:?}", version, e);
},
}
}
}
}
@@ -262,7 +266,8 @@ mod tests {
"--delay",
"12",
"seq-phragmen",
]).unwrap();
])
.unwrap();
assert_eq!(
opt,
@@ -293,7 +298,8 @@ mod tests {
"--seed-or-path",
"//Alice",
"prag-mms",
]).unwrap();
])
.unwrap();
assert_eq!(
opt,
@@ -323,7 +329,8 @@ mod tests {
"prag-mms",
"--iterations",
"1337",
]).unwrap();
])
.unwrap();
assert_eq!(
opt,