aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/chaincmd.go2
-rw-r--r--cmd/geth/main.go30
-rw-r--r--cmd/geth/usage.go4
-rw-r--r--cmd/utils/flags.go58
4 files changed, 88 insertions, 6 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index c1bbbd8dc..7a9cf4ac2 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -180,7 +180,7 @@ func exportChain(ctx *cli.Context) error {
func removeDB(ctx *cli.Context) error {
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
- dbdir := stack.ResolvePath("chaindata")
+ dbdir := stack.ResolvePath(utils.ChainDbName(ctx))
if !common.FileExist(dbdir) {
fmt.Println(dbdir, "does not exist")
return nil
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 551705208..75abdc813 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -41,6 +41,7 @@ import (
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
+ "github.com/ethereum/go-ethereum/p2p/discover"
"gopkg.in/urfave/cli.v1"
)
@@ -118,6 +119,10 @@ participating.
utils.KeyStoreDirFlag,
utils.OlympicFlag,
utils.FastSyncFlag,
+ utils.LightModeFlag,
+ utils.NoDefSrvFlag,
+ utils.LightServFlag,
+ utils.LightPeersFlag,
utils.LightKDFFlag,
utils.CacheFlag,
utils.TrieCacheGenFlag,
@@ -280,6 +285,31 @@ func startNode(ctx *cli.Context, stack *node.Node) {
// Start up the node itself
utils.StartNode(stack)
+ if ctx.GlobalBool(utils.LightModeFlag.Name) && !ctx.GlobalBool(utils.NoDefSrvFlag.Name) {
+ // add default light server; test phase only
+ addPeer := func(url string) {
+ node, err := discover.ParseNode(url)
+ if err == nil {
+ stack.Server().AddPeer(node)
+ }
+ }
+
+ if ctx.GlobalBool(utils.TestNetFlag.Name) {
+ // TestNet (John Gerryts @phonikg)
+ addPeer("enode://d72af45ba9b60851a8077a4eb07700484b585e5f2e55024e0c93b7ec7d114f2e3fa3c8f3a3358f89da00a609f5a062415deb857ada863b8cdad02b0b0bc90da3@50.112.52.169:30301")
+ } else {
+ if ctx.GlobalBool(utils.OpposeDAOFork.Name) {
+ // Classic (Azure)
+ addPeer("enode://fc3d7b57e5d317946bf421411632ec98d5ffcbf94548cd7bc10088e4fef176670f8ec70280d301a9d0b22fe498203f62b323da15b3acc18b02a1fee2a06b7d3f@40.118.3.223:30305")
+ } else {
+ // MainNet (Azure)
+ addPeer("enode://feaf206a308a669a789be45f4dadcb351246051727f12415ad69e44f8080daf0569c10fe1d9944d245dd1f3e1c89cedda8ce03d7e3d5ed8975a35cad4b4f7ec1@40.118.3.223:30303")
+ // MainNet (John Gerryts @phonikg)
+ addPeer("enode://02b80f0d47c7c157c069d0584067a284cdf188b9267666234b872e70d936a803ad20ea27f78ef1fd6425ae4b7108907e1875adbca96b038004114ac4d1e529a3@50.112.52.169:30300")
+ }
+ }
+ }
+
// Unlock any account specifically requested
accman := stack.AccountManager()
passwords := utils.MakePasswordList(ctx)
diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go
index 4c4e27630..75560d017 100644
--- a/cmd/geth/usage.go
+++ b/cmd/geth/usage.go
@@ -72,6 +72,10 @@ var AppHelpFlagGroups = []flagGroup{
utils.DevModeFlag,
utils.IdentityFlag,
utils.FastSyncFlag,
+ utils.LightModeFlag,
+ utils.NoDefSrvFlag,
+ utils.LightServFlag,
+ utils.LightPeersFlag,
utils.LightKDFFlag,
},
},
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index edb0873f6..40d96a3b5 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -39,6 +39,8 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
+ "github.com/ethereum/go-ethereum/les"
+ "github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/metrics"
@@ -145,6 +147,24 @@ var (
Name: "fast",
Usage: "Enable fast syncing through state downloads",
}
+ LightModeFlag = cli.BoolFlag{
+ Name: "light",
+ Usage: "Enable light client mode",
+ }
+ NoDefSrvFlag = cli.BoolFlag{
+ Name: "nodefsrv",
+ Usage: "Don't add default LES server (only for test version)",
+ }
+ LightServFlag = cli.IntFlag{
+ Name: "lightserv",
+ Usage: "Maximum percentage of time allowed for serving LES requests (0-90)",
+ Value: 0,
+ }
+ LightPeersFlag = cli.IntFlag{
+ Name: "lightpeers",
+ Usage: "Maximum number of LES client peers",
+ Value: 20,
+ }
LightKDFFlag = cli.BoolFlag{
Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
@@ -680,6 +700,11 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
Etherbase: MakeEtherbase(stack.AccountManager(), ctx),
ChainConfig: MakeChainConfig(ctx, stack),
FastSync: ctx.GlobalBool(FastSyncFlag.Name),
+ LightMode: ctx.GlobalBool(LightModeFlag.Name),
+ NoDefSrv: ctx.GlobalBool(NoDefSrvFlag.Name),
+ LightServ: ctx.GlobalInt(LightServFlag.Name),
+ LightPeers: ctx.GlobalInt(LightPeersFlag.Name),
+ MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
DatabaseCache: ctx.GlobalInt(CacheFlag.Name),
DatabaseHandles: MakeDatabaseHandles(),
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
@@ -714,6 +739,7 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
}
ethConf.Genesis = core.TestNetGenesisBlock()
state.StartingNonce = 1048576 // (2**20)
+ light.StartingNonce = 1048576 // (2**20)
case ctx.GlobalBool(DevModeFlag.Name):
ethConf.Genesis = core.OlympicGenesisBlock()
@@ -727,10 +753,23 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
state.MaxTrieCacheGen = uint16(gen)
}
- if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- return eth.New(ctx, ethConf)
- }); err != nil {
- Fatalf("Failed to register the Ethereum service: %v", err)
+ if ethConf.LightMode {
+ if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
+ return les.New(ctx, ethConf)
+ }); err != nil {
+ Fatalf("Failed to register the Ethereum light node service: %v", err)
+ }
+ } else {
+ if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
+ fullNode, err := eth.New(ctx, ethConf)
+ if fullNode != nil && ethConf.LightServ > 0 {
+ ls, _ := les.NewLesServer(fullNode, ethConf)
+ fullNode.AddLesServer(ls)
+ }
+ return fullNode, err
+ }); err != nil {
+ Fatalf("Failed to register the Ethereum full node service: %v", err)
+ }
}
}
@@ -830,14 +869,23 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainConfi
return config
}
+func ChainDbName(ctx *cli.Context) string {
+ if ctx.GlobalBool(LightModeFlag.Name) {
+ return "lightchaindata"
+ } else {
+ return "chaindata"
+ }
+}
+
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
var (
cache = ctx.GlobalInt(CacheFlag.Name)
handles = MakeDatabaseHandles()
+ name = ChainDbName(ctx)
)
- chainDb, err := stack.OpenDatabase("chaindata", cache, handles)
+ chainDb, err := stack.OpenDatabase(name, cache, handles)
if err != nil {
Fatalf("Could not open database: %v", err)
}