Merge pull request #1744 from kobigurk/develop

adds extradata flag
This commit is contained in:
Jeffrey Wilcke 2015-09-15 13:56:10 -07:00
commit e9a80518c7
1 changed files with 15 additions and 1 deletions

View File

@ -58,6 +58,11 @@ var (
gitCommit string // set via linker flagg gitCommit string // set via linker flagg
nodeNameVersion string nodeNameVersion string
app *cli.App app *cli.App
ExtraDataFlag = cli.StringFlag{
Name: "extradata",
Usage: "Extra data for the miner",
}
) )
func init() { func init() {
@ -331,6 +336,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.GpobaseStepDownFlag, utils.GpobaseStepDownFlag,
utils.GpobaseStepUpFlag, utils.GpobaseStepUpFlag,
utils.GpobaseCorrectionFactorFlag, utils.GpobaseCorrectionFactorFlag,
ExtraDataFlag,
} }
app.Before = func(ctx *cli.Context) error { app.Before = func(ctx *cli.Context) error {
utils.SetupLogger(ctx) utils.SetupLogger(ctx)
@ -354,6 +360,14 @@ func main() {
} }
} }
// MakeExtra resolves extradata for the miner from a flag or returns a default.
func makeExtra(ctx *cli.Context) []byte {
if ctx.GlobalIsSet(ExtraDataFlag.Name) {
return []byte(ctx.GlobalString(ExtraDataFlag.Name))
}
return makeDefaultExtra()
}
func makeDefaultExtra() []byte { func makeDefaultExtra() []byte {
var clientInfo = struct { var clientInfo = struct {
Version uint Version uint
@ -382,7 +396,7 @@ func run(ctx *cli.Context) {
} }
cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
cfg.ExtraData = makeDefaultExtra() cfg.ExtraData = makeExtra(ctx)
ethereum, err := eth.New(cfg) ethereum, err := eth.New(cfg)
if err != nil { if err != nil {