Merge pull request #1085 from ethcore/fix1073
Provide fallback for usd-per-eth option when offline.
This commit is contained in:
commit
52e22b8a51
@ -102,7 +102,9 @@ Sealing/Mining Options:
|
||||
[default: 0.005]. The minimum gas price is set
|
||||
accordingly.
|
||||
--usd-per-eth SOURCE USD value of a single ETH. SOURCE may be either an
|
||||
amount in USD or a web service [default: etherscan].
|
||||
amount in USD, a web service or 'auto' to use each
|
||||
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: 4712388].
|
||||
--author ADDRESS Specify the block author (aka "coinbase") address
|
||||
|
@ -91,11 +91,18 @@ impl Configuration {
|
||||
die!("{}: Invalid basic transaction price given in USD. Must be a decimal number.", self.args.flag_usd_per_tx)
|
||||
});
|
||||
let usd_per_eth = match self.args.flag_usd_per_eth.as_str() {
|
||||
"auto" => PriceInfo::get().map_or_else(|| {
|
||||
let last_known_good = 9.69696;
|
||||
// TODO: use #1083 to read last known good value.
|
||||
last_known_good
|
||||
}, |x| x.ethusd),
|
||||
"etherscan" => PriceInfo::get().map_or_else(|| {
|
||||
die!("Unable to retrieve USD value of ETH from etherscan. Rerun with a different value for --usd-per-eth.")
|
||||
}, |x| x.ethusd),
|
||||
x => FromStr::from_str(x).unwrap_or_else(|_| die!("{}: Invalid ether price given in USD. Must be a decimal number.", x))
|
||||
};
|
||||
// TODO: use #1083 to write last known good value as use_per_eth.
|
||||
|
||||
let wei_per_usd: f32 = 1.0e18 / usd_per_eth;
|
||||
let gas_per_tx: f32 = 21000.0;
|
||||
let wei_per_gas: f32 = wei_per_usd * usd_per_tx / gas_per_tx;
|
||||
|
Loading…
Reference in New Issue
Block a user