forked from cerc-io/plugeth
Modifications to pluGethCaptureTrieConfig
This commit is contained in:
parent
461422d52e
commit
54b4a7d9c7
@ -354,8 +354,8 @@ func geth(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stack, backend := makeFullNode(ctx)
|
stack, backend := makeFullNode(ctx)
|
||||||
tc := plugethCaptureTrieConfig(ctx, stack)
|
trieCfg := plugethCaptureTrieConfig(ctx, stack, backend)
|
||||||
wrapperBackend := backendwrapper.NewBackend(backend, tc)
|
wrapperBackend := backendwrapper.NewBackend(backend, trieCfg)
|
||||||
|
|
||||||
pluginsInitializeNode(stack, wrapperBackend)
|
pluginsInitializeNode(stack, wrapperBackend)
|
||||||
if ok, err := plugins.RunSubcommand(ctx); ok {
|
if ok, err := plugins.RunSubcommand(ctx); ok {
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
gcore "github.com/ethereum/go-ethereum/core"
|
gcore "github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
@ -132,36 +133,68 @@ func pluginBlockChain() {
|
|||||||
BlockChain(plugins.DefaultPluginLoader)
|
BlockChain(plugins.DefaultPluginLoader)
|
||||||
}
|
}
|
||||||
|
|
||||||
func plugethCaptureTrieConfig(ctx *cli.Context, stack *node.Node) *trie.Config {
|
func plugethCaptureTrieConfig(ctx *cli.Context, stack *node.Node, backend ethapi.Backend) *trie.Config {
|
||||||
|
|
||||||
ec := new(ethconfig.Config)
|
ethCfg := new(ethconfig.Config)
|
||||||
utils.SetEthConfig(ctx, stack, ec)
|
|
||||||
|
|
||||||
cc := &gcore.CacheConfig{
|
if ctx.IsSet(utils.CacheFlag.Name) || ctx.IsSet(utils.CacheTrieFlag.Name) {
|
||||||
TrieCleanLimit: ec.TrieCleanCache,
|
ethCfg.TrieCleanCache = ctx.Int(utils.CacheFlag.Name) * ctx.Int(utils.CacheTrieFlag.Name) / 100
|
||||||
TrieCleanNoPrefetch: ec.NoPrefetch,
|
}
|
||||||
TrieDirtyLimit: ec.TrieDirtyCache,
|
if ctx.IsSet(utils.CacheNoPrefetchFlag.Name) {
|
||||||
TrieDirtyDisabled: ec.NoPruning,
|
ethCfg.NoPrefetch = ctx.Bool(utils.CacheNoPrefetchFlag.Name)
|
||||||
TrieTimeLimit: ec.TrieTimeout,
|
}
|
||||||
SnapshotLimit: ec.SnapshotCache,
|
if ctx.IsSet(utils.CacheFlag.Name) || ctx.IsSet(utils.CacheGCFlag.Name) {
|
||||||
Preimages: ec.Preimages,
|
ethCfg.TrieDirtyCache = ctx.Int(utils.CacheFlag.Name) * ctx.Int(utils.CacheGCFlag.Name) / 100
|
||||||
StateHistory: ec.StateHistory,
|
}
|
||||||
StateScheme: ec.StateScheme,
|
if ctx.IsSet(utils.GCModeFlag.Name) {
|
||||||
|
ethCfg.NoPruning = ctx.String(utils.GCModeFlag.Name) == "archive"
|
||||||
|
}
|
||||||
|
if ctx.IsSet(utils.CacheFlag.Name) || ctx.IsSet(utils.CacheSnapshotFlag.Name) {
|
||||||
|
ethCfg.SnapshotCache = ctx.Int(utils.CacheFlag.Name) * ctx.Int(utils.CacheSnapshotFlag.Name) / 100
|
||||||
|
}
|
||||||
|
ethCfg.Preimages = ctx.Bool(utils.CachePreimagesFlag.Name)
|
||||||
|
if ethCfg.NoPruning && !ethCfg.Preimages {
|
||||||
|
ethCfg.Preimages = true
|
||||||
|
log.Info("Enabling recording of key preimages since archive mode is used")
|
||||||
|
}
|
||||||
|
if ctx.IsSet(utils.StateHistoryFlag.Name) {
|
||||||
|
ethCfg.StateHistory = ctx.Uint64(utils.StateHistoryFlag.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &trie.Config{Preimages: cc.Preimages}
|
chaindb := backend.ChainDb()
|
||||||
if cc.StateScheme == rawdb.HashScheme {
|
|
||||||
|
scheme, err := utils.ParseStateScheme(ctx, chaindb)
|
||||||
|
if err != nil {
|
||||||
|
utils.Fatalf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ethCfg.StateScheme = scheme
|
||||||
|
|
||||||
|
cacheCfg := &gcore.CacheConfig{
|
||||||
|
TrieCleanLimit: ethCfg.TrieCleanCache,
|
||||||
|
TrieCleanNoPrefetch: ethCfg.NoPrefetch,
|
||||||
|
TrieDirtyLimit: ethCfg.TrieDirtyCache,
|
||||||
|
TrieDirtyDisabled: ethCfg.NoPruning,
|
||||||
|
TrieTimeLimit: ethconfig.Defaults.TrieTimeout,
|
||||||
|
SnapshotLimit: ethCfg.SnapshotCache,
|
||||||
|
Preimages: ethCfg.Preimages,
|
||||||
|
StateHistory: ethCfg.StateHistory,
|
||||||
|
StateScheme: ethCfg.StateScheme,
|
||||||
|
}
|
||||||
|
|
||||||
|
config := &trie.Config{Preimages: cacheCfg.Preimages}
|
||||||
|
if cacheCfg.StateScheme == rawdb.HashScheme {
|
||||||
config.HashDB = &hashdb.Config{
|
config.HashDB = &hashdb.Config{
|
||||||
CleanCacheSize: cc.TrieCleanLimit * 1024 * 1024,
|
CleanCacheSize: cacheCfg.TrieCleanLimit * 1024 * 1024,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cc.StateScheme == rawdb.PathScheme {
|
if cacheCfg.StateScheme == rawdb.PathScheme {
|
||||||
config.PathDB = &pathdb.Config{
|
config.PathDB = &pathdb.Config{
|
||||||
StateHistory: cc.StateHistory,
|
StateHistory: cacheCfg.StateHistory,
|
||||||
CleanCacheSize: cc.TrieCleanLimit * 1024 * 1024,
|
CleanCacheSize: cacheCfg.TrieCleanLimit * 1024 * 1024,
|
||||||
DirtyCacheSize: cc.TrieDirtyLimit * 1024 * 1024,
|
DirtyCacheSize: cacheCfg.TrieDirtyLimit * 1024 * 1024,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user