New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Light client stage 1 #1684
Light client stage 1 #1684
Changes from all commits
a486c11
7a44bab
934cc7d
1c9c96f
b1250e2
0d95af0
d48f195
2c3dba3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,14 @@ import ( | |
"path/filepath" | ||
"runtime" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/codegangsta/cli" | ||
"github.com/ethereum/ethash" | ||
"github.com/ethereum/go-ethereum/accounts" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core" | ||
"github.com/ethereum/go-ethereum/les/access" | ||
"github.com/ethereum/go-ethereum/core/vm" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
"github.com/ethereum/go-ethereum/eth" | ||
|
@@ -133,11 +135,6 @@ var ( | |
Name: "natspec", | ||
Usage: "Enable NatSpec confirmation notice", | ||
} | ||
DocRootFlag = DirectoryFlag{ | ||
Name: "docroot", | ||
Usage: "Document Root for HTTPClient file scheme", | ||
Value: DirectoryString{common.HomeDir()}, | ||
} | ||
CacheFlag = cli.IntFlag{ | ||
Name: "cache", | ||
Usage: "Megabytes of memory allocated to internal caching (min 16MB / database forced)", | ||
|
@@ -156,6 +153,11 @@ var ( | |
Name: "lightkdf", | ||
Usage: "Reduce KDF memory & CPU usage at some expense of KDF strength", | ||
} | ||
EthModeFlag = cli.StringFlag{ | ||
Name: "mode", | ||
Value: "archive", | ||
Usage: "Client mode of operation (archive, full, light)", | ||
} | ||
// Miner settings | ||
// TODO: refactor CPU vs GPU mining flags | ||
MiningEnabledFlag = cli.BoolFlag{ | ||
|
@@ -424,12 +426,25 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { | |
if err != nil { | ||
glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default") | ||
} | ||
// Resolve the mode of opeation from the string flag | ||
var clientMode eth.Mode | ||
switch strings.ToLower(ctx.GlobalString(EthModeFlag.Name)) { | ||
case "archive": | ||
clientMode = eth.ArchiveMode | ||
case "full": | ||
clientMode = eth.FullMode | ||
case "light": | ||
clientMode = eth.LightMode | ||
default: | ||
glog.Fatalf("Unknown node type requested: %s", ctx.GlobalString(EthModeFlag.Name)) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please drop these. They do not make sense in the context of the ETH protocol any more. The fast sync was already integrated separately as a bool flag. Why do you need to specify this mode to the eth package? If you are a light client, you should simply never even construct an eth object, so I don't see any rational behind modifying the eth.Config and the related things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole backend is in eth, I definitely need that, I think duplicating the backend would be wrong. I just won't construct an eth ProtocolManager (I do agree about dropping NoSync, it was a bad idea). I can drop the mode flag and add a bool flag for light mode of course. |
||
// Assemble the entire eth configuration and return | ||
cfg := ð.Config{ | ||
Name: common.MakeName(clientID, version), | ||
DataDir: MustDataDir(ctx), | ||
GenesisFile: ctx.GlobalString(GenesisFileFlag.Name), | ||
FastSync: ctx.GlobalBool(FastSyncFlag.Name), | ||
Mode: clientMode, | ||
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name), | ||
DatabaseCache: ctx.GlobalInt(CacheFlag.Name), | ||
SkipBcVersionCheck: false, | ||
|
@@ -446,7 +461,6 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { | |
Olympic: ctx.GlobalBool(OlympicFlag.Name), | ||
NAT: MakeNAT(ctx), | ||
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name), | ||
DocRoot: ctx.GlobalString(DocRootFlag.Name), | ||
Discovery: !ctx.GlobalBool(NoDiscoverFlag.Name), | ||
NodeKey: MakeNodeKey(ctx), | ||
Shh: ctx.GlobalBool(WhisperEnabledFlag.Name), | ||
|
@@ -552,12 +566,12 @@ func MakeChain(ctx *cli.Context) (chain *core.BlockChain, chainDb ethdb.Database | |
eventMux := new(event.TypeMux) | ||
pow := ethash.New() | ||
//genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB) | ||
chain, err = core.NewBlockChain(chainDb, pow, eventMux) | ||
chain, err = core.NewBlockChain(access.NewDbChainAccess(chainDb), pow, eventMux) | ||
if err != nil { | ||
Fatalf("Could not start chainmanager: %v", err) | ||
} | ||
|
||
proc := core.NewBlockProcessor(chainDb, pow, chain, eventMux) | ||
proc := core.NewBlockProcessor(access.NewDbChainAccess(chainDb), pow, chain, eventMux) | ||
chain.SetProcessor(proc) | ||
return chain, chainDb | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag was dropped because it's too murky what it represents. Please rework the code so that it is based on a single
--light
flag. If it is passed, thecmd/geth/
package should initializeeth
andles
properly.