Better error messages for PoA chains
This commit is contained in:
parent
4c532f9e3d
commit
8ca0e09ffc
@ -150,6 +150,11 @@ impl AccountProvider {
|
|||||||
Ok(Address::from(address).into())
|
Ok(Address::from(address).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks whether an account with a given address is present.
|
||||||
|
pub fn has_account(&self, address: Address) -> Result<bool, Error> {
|
||||||
|
Ok(self.accounts()?.iter().any(|&a| a == address))
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns addresses of all accounts.
|
/// Returns addresses of all accounts.
|
||||||
pub fn accounts(&self) -> Result<Vec<Address>, Error> {
|
pub fn accounts(&self) -> Result<Vec<Address>, Error> {
|
||||||
let accounts = self.sstore.accounts()?;
|
let accounts = self.sstore.accounts()?;
|
||||||
|
@ -230,9 +230,21 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
|||||||
miner.set_extra_data(cmd.miner_extras.extra_data);
|
miner.set_extra_data(cmd.miner_extras.extra_data);
|
||||||
miner.set_transactions_limit(cmd.miner_extras.transactions_limit);
|
miner.set_transactions_limit(cmd.miner_extras.transactions_limit);
|
||||||
let engine_signer = cmd.miner_extras.engine_signer;
|
let engine_signer = cmd.miner_extras.engine_signer;
|
||||||
|
|
||||||
if engine_signer != Default::default() {
|
if engine_signer != Default::default() {
|
||||||
|
// Check if engine signer exists
|
||||||
|
if !account_provider.has_account(engine_signer).unwrap_or(false) {
|
||||||
|
return Err(format!("Consensus signer account not found for the current chain, please run `parity account new -d current-d --chain current-chain`"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if any passwords have been read from the password file(s)
|
||||||
|
if passwords.is_empty() {
|
||||||
|
return Err(format!("No password found for the consensus signer {}. Make sure valid password is present in files passed using `--password` or in the configuration file.", engine_signer));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to sign in the engine signer.
|
||||||
if !passwords.into_iter().any(|p| miner.set_engine_signer(engine_signer, p).is_ok()) {
|
if !passwords.into_iter().any(|p| miner.set_engine_signer(engine_signer, p).is_ok()) {
|
||||||
return Err(format!("No password found for the consensus signer {}. Make sure valid password is present in files passed using `--password`.", engine_signer));
|
return Err(format!("Invalid password for consensus signer {}. Make sure valid password is present in files passed using `--password` or in the configuration file.", engine_signer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user