Don't mine without --author (#1436)
Requires --author to be set before mining is allowed to happen.
This commit is contained in:
@@ -225,6 +225,14 @@ fn no_work_err() -> Error {
|
||||
}
|
||||
}
|
||||
|
||||
fn no_author_err() -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(error_codes::NO_AUTHOR_CODE),
|
||||
message: "Author not configured. Run parity with --author to configure.".into(),
|
||||
data: None
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
C: MiningBlockChainClient + 'static,
|
||||
S: SyncProvider + 'static,
|
||||
@@ -474,6 +482,10 @@ impl<C, S, M, EM> Eth for EthClient<C, S, M, EM> where
|
||||
}
|
||||
|
||||
let miner = take_weak!(self.miner);
|
||||
if miner.author().is_zero() {
|
||||
warn!(target: "miner", "Cannot give work package - no author is configured. Use --author to configure!");
|
||||
return Err(no_author_err())
|
||||
}
|
||||
miner.map_sealing_work(client.deref(), |b| {
|
||||
let pow_hash = b.hash();
|
||||
let target = Ethash::difficulty_to_boundary(b.block().header().difficulty());
|
||||
|
||||
@@ -68,7 +68,8 @@ mod error_codes {
|
||||
// NOTE [ToDr] Codes from [-32099, -32000]
|
||||
pub const UNSUPPORTED_REQUEST_CODE: i64 = -32000;
|
||||
pub const NO_WORK_CODE: i64 = -32001;
|
||||
pub const UNKNOWN_ERROR: i64 = -32002;
|
||||
pub const NO_AUTHOR_CODE: i64 = -32002;
|
||||
pub const UNKNOWN_ERROR: i64 = -32009;
|
||||
pub const TRANSACTION_ERROR: i64 = -32010;
|
||||
pub const ACCOUNT_LOCKED: i64 = -32020;
|
||||
pub const SIGNER_DISABLED: i64 = -32030;
|
||||
|
||||
Reference in New Issue
Block a user