aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-05-20 23:56:17 +0800
committerzelig <viktor.tron@gmail.com>2015-05-21 22:53:42 +0800
commitbed80133e0573ebeefa201a15b20188198adf0ac (patch)
treea654c1c6c671a9599290a08de2b4db95385465a1 /cmd
parent90b672f1af50944e136bdd6e617fad90f59fe6fe (diff)
downloadgo-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.tar
go-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.tar.gz
go-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.tar.bz2
go-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.tar.lz
go-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.tar.xz
go-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.tar.zst
go-tangerine-bed80133e0573ebeefa201a15b20188198adf0ac.zip
automatic DAG pregeneration for smooth epoch transitions
- backend: AutoDAG bool flag passed from cli/eth.Config to ethereum, autoDAG loop started if true - backend: autoDAG loop start/stop, remove previous DAG - cli: AutoDAG bool flag, off by default, but automatically ON if mining - admin jsre: add startAutoDAG stopAutoDAG and makeDAG in miner section - switch on/off DAG autogeneration when miner started/stopped on console
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/admin.go32
-rw-r--r--cmd/geth/main.go3
-rw-r--r--cmd/utils/flags.go5
3 files changed, 39 insertions, 1 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index 523b7c406..4c8f110e4 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -8,6 +8,7 @@ import (
"strconv"
"time"
+ "github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
@@ -73,6 +74,9 @@ func (js *jsre) adminBindings() {
miner.Set("hashrate", js.hashrate)
miner.Set("setExtra", js.setExtra)
miner.Set("setGasPrice", js.setGasPrice)
+ miner.Set("startAutoDAG", js.startAutoDAG)
+ miner.Set("stopAutoDAG", js.stopAutoDAG)
+ miner.Set("makeDAG", js.makeDAG)
admin.Set("debug", struct{}{})
t, _ = admin.Get("debug")
@@ -278,6 +282,30 @@ func (js *jsre) hashrate(otto.FunctionCall) otto.Value {
return js.re.ToVal(js.ethereum.Miner().HashRate())
}
+func (js *jsre) makeDAG(call otto.FunctionCall) otto.Value {
+ blockNumber, err := call.Argument(1).ToInteger()
+ if err != nil {
+ fmt.Println(err)
+ return otto.FalseValue()
+ }
+
+ err = ethash.MakeDAG(uint64(blockNumber), "")
+ if err != nil {
+ return otto.FalseValue()
+ }
+ return otto.TrueValue()
+}
+
+func (js *jsre) startAutoDAG(otto.FunctionCall) otto.Value {
+ js.ethereum.StartAutoDAG()
+ return otto.TrueValue()
+}
+
+func (js *jsre) stopAutoDAG(otto.FunctionCall) otto.Value {
+ js.ethereum.StopAutoDAG()
+ return otto.TrueValue()
+}
+
func (js *jsre) backtrace(call otto.FunctionCall) otto.Value {
tracestr, err := call.Argument(0).ToString()
if err != nil {
@@ -316,6 +344,9 @@ func (js *jsre) startMining(call otto.FunctionCall) otto.Value {
threads = int64(js.ethereum.MinerThreads)
}
+ // switch on DAG autogeneration when miner starts
+ js.ethereum.StartAutoDAG()
+
err = js.ethereum.StartMining(int(threads))
if err != nil {
fmt.Println(err)
@@ -327,6 +358,7 @@ func (js *jsre) startMining(call otto.FunctionCall) otto.Value {
func (js *jsre) stopMining(call otto.FunctionCall) otto.Value {
js.ethereum.StopMining()
+ js.ethereum.StopAutoDAG()
return otto.TrueValue()
}
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index ba253bbeb..6d345a18b 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -117,7 +117,7 @@ passwordfile as argument containing the wallet password in plaintext.
Manage accounts lets you create new accounts, list all existing accounts,
import a private key into a new account.
-'account help' shows a list of subcommands or help for one subcommand.
+' help' shows a list of subcommands or help for one subcommand.
It supports interactive mode, when you are prompted for password as well as
non-interactive mode where passwords are supplied via a given password file.
@@ -257,6 +257,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.GasPriceFlag,
utils.MinerThreadsFlag,
utils.MiningEnabledFlag,
+ utils.AutoDAGFlag,
utils.NATFlag,
utils.NatspecEnabledFlag,
utils.NodeKeyFileFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 2766e7517..cb774aa5b 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -112,6 +112,10 @@ var (
Name: "mine",
Usage: "Enable mining",
}
+ AutoDAGFlag = cli.BoolFlag{
+ Name: "autodag",
+ Usage: "Enable automatic DAG pregeneration",
+ }
EtherbaseFlag = cli.StringFlag{
Name: "etherbase",
Usage: "Public address for block mining rewards. By default the address of your primary account is used",
@@ -314,6 +318,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
BootNodes: ctx.GlobalString(BootnodesFlag.Name),
GasPrice: common.String2Big(ctx.GlobalString(GasPriceFlag.Name)),
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
+ AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name),
}
}