diff options
author | Determinant <[email protected]> | 2019-08-14 01:37:25 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-08-14 01:37:25 -0400 |
commit | 592f21f5b97e5b1e714f194ae90ab83e6547cf41 (patch) | |
tree | c500cdf4ca4266af15703eca182df34d66715918 /cmd | |
parent | ad886faec521f1edcb90f6f8eb4555608d085312 (diff) |
finish a full chain example (with p2p network)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/config.go | 6 | ||||
-rw-r--r-- | cmd/geth/consolecmd.go | 2 | ||||
-rw-r--r-- | cmd/geth/main.go | 9 | ||||
-rw-r--r-- | cmd/utils/cmd.go | 2 | ||||
-rw-r--r-- | cmd/utils/flags.go | 88 |
5 files changed, 32 insertions, 75 deletions
diff --git a/cmd/geth/config.go b/cmd/geth/config.go index e33b367..d7484ab 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -28,8 +28,8 @@ import ( "github.com/Determinant/coreth/cmd/utils" "github.com/ethereum/go-ethereum/dashboard" - "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/node" + "github.com/Determinant/coreth/eth" + "github.com/Determinant/coreth/node" "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "github.com/naoina/toml" @@ -109,7 +109,7 @@ func defaultNodeConfig() node.Config { func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { // Load defaults. cfg := gethConfig{ - Eth: eth.DefaultConfig, + Eth: eth.MyDefaultConfig(), Shh: whisper.DefaultConfig, Node: defaultNodeConfig(), Dashboard: dashboard.DefaultConfig, diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 0c0881b..3cf9192 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -26,7 +26,7 @@ import ( "github.com/Determinant/coreth/cmd/utils" "github.com/ethereum/go-ethereum/console" - "github.com/ethereum/go-ethereum/node" + "github.com/Determinant/coreth/node" "github.com/ethereum/go-ethereum/rpc" "gopkg.in/urfave/cli.v1" ) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a8ddd44..56b838d 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -31,14 +31,14 @@ import ( "github.com/Determinant/coreth/cmd/utils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/console" - "github.com/ethereum/go-ethereum/eth" + "github.com/Determinant/coreth/eth" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/ethclient" "github.com/Determinant/coreth/internal/debug" "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/node" + "github.com/Determinant/coreth/node" cli "gopkg.in/urfave/cli.v1" ) @@ -380,6 +380,11 @@ func startNode(ctx *cli.Context, stack *node.Node) { if err := stack.Service(ðereum); err != nil { utils.Fatalf("Ethereum service not running: %v", err) } + etherBase := &common.Address { + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } + ethereum.SetEtherbase(*etherBase) // Set the gas price to the limits from the CLI and start mining gasprice := utils.GlobalBig(ctx, utils.MinerLegacyGasPriceFlag.Name) if ctx.IsSet(utils.MinerGasPriceFlag.Name) { diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index 97597bb..91b1bb5 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -35,7 +35,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/Determinant/coreth/internal/debug" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/node" + "github.com/Determinant/coreth/node" "github.com/ethereum/go-ethereum/rlp" ) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7e28dff..54dc9cd 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -40,18 +40,17 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/dashboard" - "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" + "github.com/Determinant/coreth/eth" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/ethstats" + "github.com/Determinant/coreth/ethstats" "github.com/ethereum/go-ethereum/graphql" - "github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/influxdb" "github.com/ethereum/go-ethereum/miner" - "github.com/ethereum/go-ethereum/node" + "github.com/Determinant/coreth/node" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discv5" "github.com/ethereum/go-ethereum/p2p/enode" @@ -960,41 +959,6 @@ func setIPC(ctx *cli.Context, cfg *node.Config) { } } -// setLes configures the les server and ultra light client settings from the command line flags. -func setLes(ctx *cli.Context, cfg *eth.Config) { - if ctx.GlobalIsSet(LightLegacyServFlag.Name) { - cfg.LightServ = ctx.GlobalInt(LightLegacyServFlag.Name) - } - if ctx.GlobalIsSet(LightServeFlag.Name) { - cfg.LightServ = ctx.GlobalInt(LightServeFlag.Name) - } - if ctx.GlobalIsSet(LightIngressFlag.Name) { - cfg.LightIngress = ctx.GlobalInt(LightIngressFlag.Name) - } - if ctx.GlobalIsSet(LightEgressFlag.Name) { - cfg.LightEgress = ctx.GlobalInt(LightEgressFlag.Name) - } - if ctx.GlobalIsSet(LightLegacyPeersFlag.Name) { - cfg.LightPeers = ctx.GlobalInt(LightLegacyPeersFlag.Name) - } - if ctx.GlobalIsSet(LightMaxPeersFlag.Name) { - cfg.LightPeers = ctx.GlobalInt(LightMaxPeersFlag.Name) - } - if ctx.GlobalIsSet(UltraLightServersFlag.Name) { - cfg.UltraLightServers = strings.Split(ctx.GlobalString(UltraLightServersFlag.Name), ",") - } - if ctx.GlobalIsSet(UltraLightFractionFlag.Name) { - cfg.UltraLightFraction = ctx.GlobalInt(UltraLightFractionFlag.Name) - } - if cfg.UltraLightFraction <= 0 && cfg.UltraLightFraction > 100 { - log.Error("Ultra light fraction is invalid", "had", cfg.UltraLightFraction, "updated", eth.DefaultConfig.UltraLightFraction) - cfg.UltraLightFraction = eth.DefaultConfig.UltraLightFraction - } - if ctx.GlobalIsSet(UltraLightOnlyAnnounceFlag.Name) { - cfg.UltraLightOnlyAnnounce = ctx.GlobalBool(UltraLightOnlyAnnounceFlag.Name) - } -} - // makeDatabaseHandles raises out the number of allowed file handles per process // for Geth and returns half of the allowance to assign to the database. func makeDatabaseHandles() int { @@ -1411,7 +1375,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { setEthash(ctx, cfg) setMiner(ctx, &cfg.Miner) setWhitelist(ctx, cfg) - setLes(ctx, cfg) if ctx.GlobalIsSet(SyncModeFlag.Name) { cfg.SyncMode = *GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode) @@ -1513,24 +1476,21 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) { // RegisterEthService adds an Ethereum client to the stack. func RegisterEthService(stack *node.Node, cfg *eth.Config) { - var err error - if cfg.SyncMode == downloader.LightSync { - err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - return les.New(ctx, cfg) - }) - } else { - err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - fullNode, err := eth.New(ctx, cfg) - if fullNode != nil && cfg.LightServ > 0 { - ls, _ := les.NewLesServer(fullNode, cfg) - fullNode.AddLesServer(ls) - } - return fullNode, err - }) - } - if err != nil { - Fatalf("Failed to register the Ethereum service: %v", err) - } + var err error + if cfg.SyncMode == downloader.LightSync { + panic("not supported") + } else { + err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + fullNode, err := eth.New(ctx, cfg) + if fullNode != nil && cfg.LightServ > 0 { + panic("not supported") + } + return fullNode, err + }) + } + if err != nil { + Fatalf("Failed to register the Ethereum service: %v", err) + } } // RegisterDashboardService adds a dashboard to the stack. @@ -1553,15 +1513,12 @@ func RegisterShhService(stack *node.Node, cfg *whisper.Config) { // the given node. func RegisterEthStatsService(stack *node.Node, url string) { if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { - // Retrieve both eth and les services + // Retrieve both eth service var ethServ *eth.Ethereum ctx.Service(ðServ) - var lesServ *les.LightEthereum - ctx.Service(&lesServ) - // Let ethstats use whichever is not nil - return ethstats.New(url, ethServ, lesServ) + return ethstats.New(url, ethServ, nil) }); err != nil { Fatalf("Failed to register the Ethereum Stats service: %v", err) } @@ -1575,11 +1532,6 @@ func RegisterGraphQLService(stack *node.Node, endpoint string, cors, vhosts []st if err := ctx.Service(ðServ); err == nil { return graphql.New(ethServ.APIBackend, endpoint, cors, vhosts, timeouts) } - // Try to construct the GraphQL service backed by a light node - var lesServ *les.LightEthereum - if err := ctx.Service(&lesServ); err == nil { - return graphql.New(lesServ.ApiBackend, endpoint, cors, vhosts, timeouts) - } // Well, this should not have happened, bail out return nil, errors.New("no Ethereum service") }); err != nil { |