diff options
-rw-r--r-- | cmd/geth/main.go | 16 | ||||
-rw-r--r-- | common/compiler/solidity.go | 22 | ||||
-rw-r--r-- | common/compiler/solidity_test.go | 6 |
3 files changed, 29 insertions, 15 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index ba753a493..f546f89cc 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -58,6 +58,11 @@ var ( gitCommit string // set via linker flagg nodeNameVersion string app *cli.App + + ExtraDataFlag = cli.StringFlag{ + Name: "extradata", + Usage: "Extra data for the miner", + } ) func init() { @@ -331,6 +336,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.GpobaseStepDownFlag, utils.GpobaseStepUpFlag, utils.GpobaseCorrectionFactorFlag, + ExtraDataFlag, } app.Before = func(ctx *cli.Context) error { 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 { var clientInfo = struct { Version uint @@ -382,7 +396,7 @@ func run(ctx *cli.Context) { } cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) - cfg.ExtraData = makeDefaultExtra() + cfg.ExtraData = makeExtra(ctx) ethereum, err := eth.New(cfg) if err != nil { diff --git a/common/compiler/solidity.go b/common/compiler/solidity.go index 5ded4fc6e..aca3a1fc2 100644 --- a/common/compiler/solidity.go +++ b/common/compiler/solidity.go @@ -35,8 +35,8 @@ import ( ) var ( - versionRegExp = regexp.MustCompile("[0-9]+\\.[0-9]+\\.[0-9]+") - newAPIRegexp = regexp.MustCompile("0\\.1\\.[2-9][0-9]*") + versionRegexp = regexp.MustCompile("[0-9]+\\.[0-9]+\\.[0-9]+") + legacyRegexp = regexp.MustCompile("0\\.(9\\..*|1\\.[01])") paramsLegacy = []string{ "--binary", // Request to output the contract in binary (hexadecimal). "file", // @@ -50,13 +50,13 @@ var ( "1", } paramsNew = []string{ - "--bin", // Request to output the contract in binary (hexadecimal). - "--abi", // Request to output the contract's JSON ABI interface. - "--userdoc", // Request to output the contract's Natspec user documentation. - "--devdoc", // Request to output the contract's Natspec developer documentation. - "--add-std", // include standard lib contracts - "--optimize=1", // code optimizer switched on - "-o", // output directory + "--bin", // Request to output the contract in binary (hexadecimal). + "--abi", // Request to output the contract's JSON ABI interface. + "--userdoc", // Request to output the contract's Natspec user documentation. + "--devdoc", // Request to output the contract's Natspec developer documentation. + "--add-std", // include standard lib contracts + "--optimize", // code optimizer switched on + "-o", // output directory } ) @@ -102,8 +102,8 @@ func New(solcPath string) (sol *Solidity, err error) { } fullVersion := out.String() - version := versionRegExp.FindString(fullVersion) - legacy := !newAPIRegexp.MatchString(version) + version := versionRegexp.FindString(fullVersion) + legacy := legacyRegexp.MatchString(version) sol = &Solidity{ solcPath: solcPath, diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go index 905a5957c..258a78f52 100644 --- a/common/compiler/solidity_test.go +++ b/common/compiler/solidity_test.go @@ -46,9 +46,9 @@ contract test { func TestCompiler(t *testing.T) { sol, err := New("") if err != nil { - t.Skip("solc not found: skip: %v", err) + t.Skipf("solc not found: %v", err) } else if sol.Version() != solcVersion { - t.Skip("WARNING: skipping due to a newer version of solc found (%v, expect %v)", sol.Version(), solcVersion) + t.Skipf("WARNING: a newer version of solc found (%v, expect %v)", sol.Version(), solcVersion) } contracts, err := sol.Compile(source) if err != nil { @@ -83,7 +83,7 @@ func TestCompileError(t *testing.T) { func TestNoCompiler(t *testing.T) { _, err := New("/path/to/solc") if err != nil { - t.Log("solidity quits with error: %v", err) + t.Logf("solidity quits with error: %v", err) } else { t.Errorf("no solc installed, but got no error") } |