mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
Merge pull request #195 from async-la/storage-params
[Store] Allow parameters to be set via cli and env vars
This commit is contained in:
commit
d15ba94284
3 changed files with 62 additions and 15 deletions
|
|
@ -70,6 +70,10 @@ const (
|
||||||
SWARM_ENV_CORS = "SWARM_CORS"
|
SWARM_ENV_CORS = "SWARM_CORS"
|
||||||
SWARM_ENV_BOOTNODES = "SWARM_BOOTNODES"
|
SWARM_ENV_BOOTNODES = "SWARM_BOOTNODES"
|
||||||
SWARM_ENV_PSS_ENABLE = "SWARM_PSS_ENABLE"
|
SWARM_ENV_PSS_ENABLE = "SWARM_PSS_ENABLE"
|
||||||
|
SWARM_ENV_STORE_PATH = "SWARM_STORE_PATH"
|
||||||
|
SWARM_ENV_STORE_CAPACITY = "SWARM_STORE_CAPACITY"
|
||||||
|
SWARM_ENV_STORE_CACHE_CAPACITY = "SWARM_STORE_CACHE_CAPACITY"
|
||||||
|
SWARM_ENV_STORE_RADIUS = "SWARM_STORE_RADIUS"
|
||||||
GETH_ENV_DATADIR = "GETH_DATADIR"
|
GETH_ENV_DATADIR = "GETH_DATADIR"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -216,6 +220,22 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
|
||||||
currentConfig.PssEnabled = true
|
currentConfig.PssEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if storePath := ctx.GlobalString(SwarmStorePath.Name); storePath != "" {
|
||||||
|
currentConfig.StoreParams.ChunkDbPath = storePath
|
||||||
|
}
|
||||||
|
|
||||||
|
if storeCapacity := ctx.GlobalUint64(SwarmStoreCapacity.Name); storeCapacity != 0 {
|
||||||
|
currentConfig.StoreParams.DbCapacity = uint64(storeCapacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
if storeCacheCapacity := ctx.GlobalUint(SwarmStoreCacheCapacity.Name); storeCacheCapacity != 0 {
|
||||||
|
currentConfig.StoreParams.CacheCapacity = uint(storeCacheCapacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
if storeRadius := ctx.GlobalInt(SwarmStoreRadius.Name); storeRadius != 0 {
|
||||||
|
currentConfig.StoreParams.Radius = int(storeRadius)
|
||||||
|
}
|
||||||
|
|
||||||
return currentConfig
|
return currentConfig
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,26 @@ var (
|
||||||
Usage: "Domain on which to send Access-Control-Allow-Origin header (multiple domains can be supplied separated by a ',')",
|
Usage: "Domain on which to send Access-Control-Allow-Origin header (multiple domains can be supplied separated by a ',')",
|
||||||
EnvVar: SWARM_ENV_CORS,
|
EnvVar: SWARM_ENV_CORS,
|
||||||
}
|
}
|
||||||
|
SwarmStorePath = cli.StringFlag{
|
||||||
|
Name: "store.path",
|
||||||
|
Usage: "Path to leveldb chunk DB (default <$GETH_ENV_DIR>/swarm/bzz-<$BZZ_KEY>/chunks)",
|
||||||
|
EnvVar: SWARM_ENV_STORE_PATH,
|
||||||
|
}
|
||||||
|
SwarmStoreCapacity = cli.Uint64Flag{
|
||||||
|
Name: "store.size",
|
||||||
|
Usage: "Number of chunks (5M is roughly 20-25GB) (default 5000000)",
|
||||||
|
EnvVar: SWARM_ENV_STORE_CAPACITY,
|
||||||
|
}
|
||||||
|
SwarmStoreCacheCapacity = cli.UintFlag{
|
||||||
|
Name: "store.cache.size",
|
||||||
|
Usage: "Number of recent chunks cached in memory (default 5000)",
|
||||||
|
EnvVar: SWARM_ENV_STORE_CACHE_CAPACITY,
|
||||||
|
}
|
||||||
|
SwarmStoreRadius = cli.IntFlag{
|
||||||
|
Name: "store.radius",
|
||||||
|
Usage: "Minimum proximity order (number of identical prefix bits of address key) for chunks to warrant storage (default 0)",
|
||||||
|
EnvVar: SWARM_ENV_STORE_RADIUS,
|
||||||
|
}
|
||||||
|
|
||||||
// the following flags are deprecated and should be removed in the future
|
// the following flags are deprecated and should be removed in the future
|
||||||
DeprecatedEthAPIFlag = cli.StringFlag{
|
DeprecatedEthAPIFlag = cli.StringFlag{
|
||||||
|
|
@ -367,6 +387,11 @@ DEPRECATED: use 'swarm db clean'.
|
||||||
SwarmUploadMimeType,
|
SwarmUploadMimeType,
|
||||||
// pss flags
|
// pss flags
|
||||||
SwarmPssEnabledFlag,
|
SwarmPssEnabledFlag,
|
||||||
|
// storage flags
|
||||||
|
SwarmStorePath,
|
||||||
|
SwarmStoreCapacity,
|
||||||
|
SwarmStoreCacheCapacity,
|
||||||
|
SwarmStoreRadius,
|
||||||
//deprecated flags
|
//deprecated flags
|
||||||
DeprecatedEthAPIFlag,
|
DeprecatedEthAPIFlag,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,9 @@ func NewDefaultStoreParams() (self *StoreParams) {
|
||||||
//this can only finally be set after all config options (file, cmd line, env vars)
|
//this can only finally be set after all config options (file, cmd line, env vars)
|
||||||
//have been evaluated
|
//have been evaluated
|
||||||
func (self *StoreParams) Init(path string) {
|
func (self *StoreParams) Init(path string) {
|
||||||
|
if self.ChunkDbPath == "" {
|
||||||
self.ChunkDbPath = filepath.Join(path, "chunks")
|
self.ChunkDbPath = filepath.Join(path, "chunks")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// netstore contructor, takes path argument that is used to initialise dbStore,
|
// netstore contructor, takes path argument that is used to initialise dbStore,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue