Skip to content

Commit 4b977ba

Browse files
Seonpyo Kimforiequal0
authored andcommitted
Remove the cli optional argument "no-miner"
Now the default value of mining.disable is true and could be set to false not through the no-miner option but through not giving both author and engine signer options.
1 parent e5ec181 commit 4b977ba

File tree

5 files changed

+31
-40
lines changed

5 files changed

+31
-40
lines changed

codechain/codechain.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,10 @@ args:
155155
long: author
156156
help: Specify the block author (aka "coinbase") address for sending block rewards from sealed blocks.
157157
takes_value: true
158-
conflicts_with:
159-
- no-miner
160158
- engine-signer:
161159
long: engine-signer
162160
help: Specify the address which should be used to sign consensus messages and issue blocks.
163161
takes_value: true
164-
conflicts_with:
165-
- no-miner
166162
- password-path:
167163
long: password-path
168164
help: Specify the password file path.

codechain/config/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ pub struct Operating {
215215
#[derive(Deserialize)]
216216
#[serde(deny_unknown_fields)]
217217
pub struct Mining {
218-
pub disable: Option<bool>,
219218
pub author: Option<PlatformAddress>,
220219
pub engine_signer: Option<PlatformAddress>,
221220
pub mem_pool_size: Option<usize>,
@@ -374,9 +373,6 @@ impl Operating {
374373

375374
impl Mining {
376375
pub fn merge(&mut self, other: &Mining) {
377-
if other.disable.is_some() {
378-
self.disable = other.disable;
379-
}
380376
if other.author.is_some() {
381377
self.author = other.author;
382378
}
@@ -416,16 +412,17 @@ impl Mining {
416412
}
417413

418414
pub fn overwrite_with(&mut self, matches: &clap::ArgMatches) -> Result<(), String> {
419-
if matches.is_present("no-miner") {
420-
self.disable = Some(true);
421-
}
422-
423415
if let Some(author) = matches.value_of("author") {
424416
self.author = Some(author.parse().map_err(|_| "Invalid address format")?);
425417
}
426418
if let Some(engine_signer) = matches.value_of("engine-signer") {
427419
self.engine_signer = Some(engine_signer.parse().map_err(|_| "Invalid address format")?);
428420
}
421+
if matches.is_present("no-miner") {
422+
self.author = None;
423+
self.engine_signer = None;
424+
println!("This option was deprecated. PoW type engine with no engine signer and PBFT or PoA type engine with no author implicitly means no-miner.");
425+
}
429426
if let Some(mem_pool_fee_bump_shift) = matches.value_of("mem-pool-fee-bump-shift") {
430427
self.mem_pool_mem_limit =
431428
Some(mem_pool_fee_bump_shift.parse().map_err(|_| "Invalid mem pool fee bump shift")?);

codechain/config/presets/config.dev.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ base_path = "."
44
chain = "solo"
55

66
[mining]
7-
disable = false
87
mem_pool_mem_limit = 4 # MB
98
mem_pool_size = 32768
109
mem_pool_fee_bump_shift = 3 # 12.5%

codechain/config/presets/config.prod.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ base_path = "."
44
chain = "mainnet"
55

66
[mining]
7-
disable = false
87
mem_pool_mem_limit = 512 # MB
98
mem_pool_size = 524288
109
mem_pool_fee_bump_shift = 3 # 12.5%

codechain/run_node.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,34 +126,34 @@ fn new_miner(
126126
) -> Result<Arc<Miner>, String> {
127127
let miner = Miner::new(config.miner_options()?, scheme, Some(ap), db);
128128

129-
if !config.mining.disable.unwrap() {
130-
match miner.engine_type() {
131-
EngineType::PoW => match &config.mining.author {
132-
Some(ref author) => {
133-
miner.set_author((*author).into_address()).expect("set_author never fails when PoW is used")
134-
}
135-
None => return Err("The author is missing. Specify the author using --author option.".to_string()),
136-
},
137-
EngineType::PBFT | EngineType::PoA => match &config.mining.engine_signer {
138-
Some(ref engine_signer) => match miner.set_author((*engine_signer).into_address()) {
139-
Err(AccountProviderError::NotUnlocked) => {
140-
return Err(
141-
"The account is not unlocked. Specify the password path using --password-path option."
142-
.to_string(),
143-
)
144-
}
145-
Err(e) => return Err(format!("{}", e)),
146-
_ => (),
147-
},
148-
None => {
149-
return Err("The engine signer is missing. Specify the engine signer using --engine-signer option."
150-
.to_string())
129+
match miner.engine_type() {
130+
EngineType::PoW => match &config.mining.author {
131+
Some(ref author) => {
132+
miner.set_author((*author).into_address()).expect("set_author never fails when PoW is used")
133+
}
134+
None if config.mining.engine_signer.is_some() => return Err("PoW type engine needs not an engine-signer but an author for mining. Specify the author using --author option.".to_string()),
135+
None => (),
136+
},
137+
EngineType::PBFT | EngineType::PoA => match &config.mining.engine_signer {
138+
Some(ref engine_signer) => match miner.set_author((*engine_signer).into_address()) {
139+
Err(AccountProviderError::NotUnlocked) => {
140+
return Err(
141+
"The account is not unlocked. Specify the password path using --password-path option."
142+
.to_string(),
143+
)
151144
}
145+
Err(e) => return Err(format!("{}", e)),
146+
_ => (),
152147
},
153-
EngineType::Solo => miner
154-
.set_author(config.mining.author.map_or(Address::default(), PlatformAddress::into_address))
155-
.expect("set_author never fails when Solo is used"),
156-
}
148+
None if config.mining.author.is_some() => {
149+
return Err("PBFT or PoA type engine needs not an author but an engine signer for mining. Specify the engine signer using --engine-signer option."
150+
.to_string())
151+
}
152+
None => (),
153+
},
154+
EngineType::Solo => miner
155+
.set_author(config.mining.author.map_or(Address::default(), PlatformAddress::into_address))
156+
.expect("set_author never fails when Solo is used"),
157157
}
158158

159159
Ok(miner)

0 commit comments

Comments
 (0)