Rearrange fork CLI options. (#1476)

* Rearrange fork CLI options.

* Fixed compilation
This commit is contained in:
Gav Wood 2016-06-29 09:28:56 +02:00 committed by GitHub
parent 91aee536ca
commit e3214c63c6
2 changed files with 30 additions and 17 deletions

View File

@ -42,14 +42,12 @@ Protocol Options:
--keys-path PATH Specify the path for JSON key files to be found
[default: $HOME/.parity/keys].
--identity NAME Specify your node's name.
DAO-Rescue Soft-fork Options:
--help-rescue-dao Does nothing - on by default.
--dont-help-rescue-dao Votes against the DAO-rescue soft-fork, but supports
it if it is triggered anyway.
Equivalent to --gas-floor-target=3141592.
--dogmatic Ignores all DAO-rescue soft-fork behaviour. Even if
it means losing mining rewards.
--fork POLICY Specifies the client's fork policy. POLICY must be
one of:
dogmatic - sticks rigidly to the standard chain.
dao-soft - votes for the DAO-rescue soft-fork.
normal - goes with whatever fork is decided but
votes for none. [default: normal].
Account Options:
--unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution.
@ -157,9 +155,9 @@ Sealing/Mining Options:
web service in turn and fallback on the last known
good value [default: auto].
--gas-floor-target GAS Amount of gas per block to target when sealing a new
block [default: 3141592].
block [default: 4700000].
--gas-cap GAS A cap on how large we will raise the gas limit per
block due to transaction volume [default: 3141592].
block due to transaction volume [default: 6283184].
--extra-data STRING Specify a custom extra-data for authored blocks, no
more than 32 characters.
--tx-queue-size LIMIT Maximum amount of transactions in the queue (waiting
@ -262,8 +260,7 @@ pub struct Args {
pub flag_chain: String,
pub flag_db_path: String,
pub flag_identity: String,
pub flag_dont_help_rescue_dao: bool,
pub flag_dogmatic: bool,
pub flag_fork: String,
pub flag_unlock: Option<String>,
pub flag_password: Vec<String>,
pub flag_cache: Option<usize>,

View File

@ -45,6 +45,13 @@ pub struct Directories {
pub signer: String,
}
#[derive(Eq, PartialEq, Debug)]
pub enum Policy {
DaoSoft,
Normal,
Dogmatic,
}
impl Configuration {
pub fn parse() -> Self {
Configuration {
@ -107,9 +114,18 @@ impl Configuration {
}))
}
pub fn policy(&self) -> Policy {
match self.args.flag_fork.as_str() {
"dao-soft" => Policy::DaoSoft,
"normal" => Policy::Normal,
"dogmatic" => Policy::Dogmatic,
x => die!("{}: Invalid value given for --policy option. Use --help for more info.", x)
}
}
pub fn gas_floor_target(&self) -> U256 {
if self.args.flag_dont_help_rescue_dao || self.args.flag_dogmatic {
4_700_000.into()
if self.policy() == Policy::DaoSoft {
3_141_592.into()
} else {
let d = &self.args.flag_gas_floor_target;
U256::from_dec_str(d).unwrap_or_else(|_| {
@ -119,8 +135,8 @@ impl Configuration {
}
pub fn gas_ceil_target(&self) -> U256 {
if self.args.flag_dont_help_rescue_dao || self.args.flag_dogmatic {
10_000_000.into()
if self.policy() == Policy::DaoSoft {
3_141_592.into()
} else {
let d = &self.args.flag_gas_cap;
U256::from_dec_str(d).unwrap_or_else(|_| {
@ -172,7 +188,7 @@ impl Configuration {
pub fn spec(&self) -> Spec {
match self.chain().as_str() {
"frontier" | "homestead" | "mainnet" => ethereum::new_frontier(!self.args.flag_dogmatic),
"frontier" | "homestead" | "mainnet" => ethereum::new_frontier(self.policy() != Policy::Dogmatic),
"morden" | "testnet" => ethereum::new_morden(),
"olympic" => ethereum::new_olympic(),
f => Spec::load(contents(f).unwrap_or_else(|_| {