cmd,swarm: enforce camel case variable names (#19060)
This commit is contained in:
parent
64d10c0872
commit
90b6cdaadf
@ -59,31 +59,31 @@ var (
|
|||||||
|
|
||||||
//constants for environment variables
|
//constants for environment variables
|
||||||
const (
|
const (
|
||||||
SWARM_ENV_CHEQUEBOOK_ADDR = "SWARM_CHEQUEBOOK_ADDR"
|
SwarmEnvChequebookAddr = "SWARM_CHEQUEBOOK_ADDR"
|
||||||
SWARM_ENV_ACCOUNT = "SWARM_ACCOUNT"
|
SwarmEnvAccount = "SWARM_ACCOUNT"
|
||||||
SWARM_ENV_LISTEN_ADDR = "SWARM_LISTEN_ADDR"
|
SwarmEnvListenAddr = "SWARM_LISTEN_ADDR"
|
||||||
SWARM_ENV_PORT = "SWARM_PORT"
|
SwarmEnvPort = "SWARM_PORT"
|
||||||
SWARM_ENV_NETWORK_ID = "SWARM_NETWORK_ID"
|
SwarmEnvNetworkID = "SWARM_NETWORK_ID"
|
||||||
SWARM_ENV_SWAP_ENABLE = "SWARM_SWAP_ENABLE"
|
SwarmEnvSwapEnable = "SWARM_SWAP_ENABLE"
|
||||||
SWARM_ENV_SWAP_API = "SWARM_SWAP_API"
|
SwarmEnvSwapAPI = "SWARM_SWAP_API"
|
||||||
SWARM_ENV_SYNC_DISABLE = "SWARM_SYNC_DISABLE"
|
SwarmEnvSyncDisable = "SWARM_SYNC_DISABLE"
|
||||||
SWARM_ENV_SYNC_UPDATE_DELAY = "SWARM_ENV_SYNC_UPDATE_DELAY"
|
SwarmEnvSyncUpdateDelay = "SWARM_ENV_SYNC_UPDATE_DELAY"
|
||||||
SWARM_ENV_MAX_STREAM_PEER_SERVERS = "SWARM_ENV_MAX_STREAM_PEER_SERVERS"
|
SwarmEnvMaxStreamPeerServers = "SWARM_ENV_MAX_STREAM_PEER_SERVERS"
|
||||||
SWARM_ENV_LIGHT_NODE_ENABLE = "SWARM_LIGHT_NODE_ENABLE"
|
SwarmEnvLightNodeEnable = "SWARM_LIGHT_NODE_ENABLE"
|
||||||
SWARM_ENV_DELIVERY_SKIP_CHECK = "SWARM_DELIVERY_SKIP_CHECK"
|
SwarmEnvDeliverySkipCheck = "SWARM_DELIVERY_SKIP_CHECK"
|
||||||
SWARM_ENV_ENS_API = "SWARM_ENS_API"
|
SwarmEnvENSAPI = "SWARM_ENS_API"
|
||||||
SWARM_ENV_ENS_ADDR = "SWARM_ENS_ADDR"
|
SwarmEnvENSAddr = "SWARM_ENS_ADDR"
|
||||||
SWARM_ENV_CORS = "SWARM_CORS"
|
SwarmEnvCORS = "SWARM_CORS"
|
||||||
SWARM_ENV_BOOTNODES = "SWARM_BOOTNODES"
|
SwarmEnvBootnodes = "SWARM_BOOTNODES"
|
||||||
SWARM_ENV_PSS_ENABLE = "SWARM_PSS_ENABLE"
|
SwarmEnvPSSEnable = "SWARM_PSS_ENABLE"
|
||||||
SWARM_ENV_STORE_PATH = "SWARM_STORE_PATH"
|
SwarmEnvStorePath = "SWARM_STORE_PATH"
|
||||||
SWARM_ENV_STORE_CAPACITY = "SWARM_STORE_CAPACITY"
|
SwarmEnvStoreCapacity = "SWARM_STORE_CAPACITY"
|
||||||
SWARM_ENV_STORE_CACHE_CAPACITY = "SWARM_STORE_CACHE_CAPACITY"
|
SwarmEnvStoreCacheCapacity = "SWARM_STORE_CACHE_CAPACITY"
|
||||||
SWARM_ENV_BOOTNODE_MODE = "SWARM_BOOTNODE_MODE"
|
SwarmEnvBootnodeMode = "SWARM_BOOTNODE_MODE"
|
||||||
SWARM_ACCESS_PASSWORD = "SWARM_ACCESS_PASSWORD"
|
SwarmAccessPassword = "SWARM_ACCESS_PASSWORD"
|
||||||
SWARM_AUTO_DEFAULTPATH = "SWARM_AUTO_DEFAULTPATH"
|
SwarmAutoDefaultPath = "SWARM_AUTO_DEFAULTPATH"
|
||||||
SWARM_GLOBALSTORE_API = "SWARM_GLOBALSTORE_API"
|
SwarmGlobalstoreAPI = "SWARM_GLOBALSTORE_API"
|
||||||
GETH_ENV_DATADIR = "GETH_DATADIR"
|
GethEnvDataDir = "GETH_DATADIR"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These settings ensure that TOML keys use the same names as Go struct fields.
|
// These settings ensure that TOML keys use the same names as Go struct fields.
|
||||||
@ -227,7 +227,7 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
|
|||||||
|
|
||||||
currentConfig.SwapAPI = ctx.GlobalString(SwarmSwapAPIFlag.Name)
|
currentConfig.SwapAPI = ctx.GlobalString(SwarmSwapAPIFlag.Name)
|
||||||
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" {
|
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" {
|
||||||
utils.Fatalf(SWARM_ERR_SWAP_SET_NO_API)
|
utils.Fatalf(SwarmErrSwapSetNoAPI)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.GlobalIsSet(EnsAPIFlag.Name) {
|
if ctx.GlobalIsSet(EnsAPIFlag.Name) {
|
||||||
@ -274,113 +274,113 @@ func cmdLineOverride(currentConfig *bzzapi.Config, ctx *cli.Context) *bzzapi.Con
|
|||||||
// envVarsOverride overrides the current config with whatver is provided in environment variables
|
// envVarsOverride overrides the current config with whatver is provided in environment variables
|
||||||
// most values are not allowed a zero value (empty string), if not otherwise noted
|
// most values are not allowed a zero value (empty string), if not otherwise noted
|
||||||
func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
|
func envVarsOverride(currentConfig *bzzapi.Config) (config *bzzapi.Config) {
|
||||||
if keyid := os.Getenv(SWARM_ENV_ACCOUNT); keyid != "" {
|
if keyid := os.Getenv(SwarmEnvAccount); keyid != "" {
|
||||||
currentConfig.BzzAccount = keyid
|
currentConfig.BzzAccount = keyid
|
||||||
}
|
}
|
||||||
|
|
||||||
if chbookaddr := os.Getenv(SWARM_ENV_CHEQUEBOOK_ADDR); chbookaddr != "" {
|
if chbookaddr := os.Getenv(SwarmEnvChequebookAddr); chbookaddr != "" {
|
||||||
currentConfig.Contract = common.HexToAddress(chbookaddr)
|
currentConfig.Contract = common.HexToAddress(chbookaddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if networkid := os.Getenv(SWARM_ENV_NETWORK_ID); networkid != "" {
|
if networkid := os.Getenv(SwarmEnvNetworkID); networkid != "" {
|
||||||
id, err := strconv.ParseUint(networkid, 10, 64)
|
id, err := strconv.ParseUint(networkid, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_NETWORK_ID, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvNetworkID, err)
|
||||||
}
|
}
|
||||||
if id != 0 {
|
if id != 0 {
|
||||||
currentConfig.NetworkID = id
|
currentConfig.NetworkID = id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if datadir := os.Getenv(GETH_ENV_DATADIR); datadir != "" {
|
if datadir := os.Getenv(GethEnvDataDir); datadir != "" {
|
||||||
currentConfig.Path = expandPath(datadir)
|
currentConfig.Path = expandPath(datadir)
|
||||||
}
|
}
|
||||||
|
|
||||||
bzzport := os.Getenv(SWARM_ENV_PORT)
|
bzzport := os.Getenv(SwarmEnvPort)
|
||||||
if len(bzzport) > 0 {
|
if len(bzzport) > 0 {
|
||||||
currentConfig.Port = bzzport
|
currentConfig.Port = bzzport
|
||||||
}
|
}
|
||||||
|
|
||||||
if bzzaddr := os.Getenv(SWARM_ENV_LISTEN_ADDR); bzzaddr != "" {
|
if bzzaddr := os.Getenv(SwarmEnvListenAddr); bzzaddr != "" {
|
||||||
currentConfig.ListenAddr = bzzaddr
|
currentConfig.ListenAddr = bzzaddr
|
||||||
}
|
}
|
||||||
|
|
||||||
if swapenable := os.Getenv(SWARM_ENV_SWAP_ENABLE); swapenable != "" {
|
if swapenable := os.Getenv(SwarmEnvSwapEnable); swapenable != "" {
|
||||||
swap, err := strconv.ParseBool(swapenable)
|
swap, err := strconv.ParseBool(swapenable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SWAP_ENABLE, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSwapEnable, err)
|
||||||
}
|
}
|
||||||
currentConfig.SwapEnabled = swap
|
currentConfig.SwapEnabled = swap
|
||||||
}
|
}
|
||||||
|
|
||||||
if syncdisable := os.Getenv(SWARM_ENV_SYNC_DISABLE); syncdisable != "" {
|
if syncdisable := os.Getenv(SwarmEnvSyncDisable); syncdisable != "" {
|
||||||
sync, err := strconv.ParseBool(syncdisable)
|
sync, err := strconv.ParseBool(syncdisable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SYNC_DISABLE, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSyncDisable, err)
|
||||||
}
|
}
|
||||||
currentConfig.SyncEnabled = !sync
|
currentConfig.SyncEnabled = !sync
|
||||||
}
|
}
|
||||||
|
|
||||||
if v := os.Getenv(SWARM_ENV_DELIVERY_SKIP_CHECK); v != "" {
|
if v := os.Getenv(SwarmEnvDeliverySkipCheck); v != "" {
|
||||||
skipCheck, err := strconv.ParseBool(v)
|
skipCheck, err := strconv.ParseBool(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
currentConfig.DeliverySkipCheck = skipCheck
|
currentConfig.DeliverySkipCheck = skipCheck
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v := os.Getenv(SWARM_ENV_SYNC_UPDATE_DELAY); v != "" {
|
if v := os.Getenv(SwarmEnvSyncUpdateDelay); v != "" {
|
||||||
d, err := time.ParseDuration(v)
|
d, err := time.ParseDuration(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_SYNC_UPDATE_DELAY, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvSyncUpdateDelay, err)
|
||||||
}
|
}
|
||||||
currentConfig.SyncUpdateDelay = d
|
currentConfig.SyncUpdateDelay = d
|
||||||
}
|
}
|
||||||
|
|
||||||
if max := os.Getenv(SWARM_ENV_MAX_STREAM_PEER_SERVERS); max != "" {
|
if max := os.Getenv(SwarmEnvMaxStreamPeerServers); max != "" {
|
||||||
m, err := strconv.Atoi(max)
|
m, err := strconv.Atoi(max)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_MAX_STREAM_PEER_SERVERS, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvMaxStreamPeerServers, err)
|
||||||
}
|
}
|
||||||
currentConfig.MaxStreamPeerServers = m
|
currentConfig.MaxStreamPeerServers = m
|
||||||
}
|
}
|
||||||
|
|
||||||
if lne := os.Getenv(SWARM_ENV_LIGHT_NODE_ENABLE); lne != "" {
|
if lne := os.Getenv(SwarmEnvLightNodeEnable); lne != "" {
|
||||||
lightnode, err := strconv.ParseBool(lne)
|
lightnode, err := strconv.ParseBool(lne)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_LIGHT_NODE_ENABLE, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvLightNodeEnable, err)
|
||||||
}
|
}
|
||||||
currentConfig.LightNodeEnabled = lightnode
|
currentConfig.LightNodeEnabled = lightnode
|
||||||
}
|
}
|
||||||
|
|
||||||
if swapapi := os.Getenv(SWARM_ENV_SWAP_API); swapapi != "" {
|
if swapapi := os.Getenv(SwarmEnvSwapAPI); swapapi != "" {
|
||||||
currentConfig.SwapAPI = swapapi
|
currentConfig.SwapAPI = swapapi
|
||||||
}
|
}
|
||||||
|
|
||||||
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" {
|
if currentConfig.SwapEnabled && currentConfig.SwapAPI == "" {
|
||||||
utils.Fatalf(SWARM_ERR_SWAP_SET_NO_API)
|
utils.Fatalf(SwarmErrSwapSetNoAPI)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ensapi := os.Getenv(SWARM_ENV_ENS_API); ensapi != "" {
|
if ensapi := os.Getenv(SwarmEnvENSAPI); ensapi != "" {
|
||||||
currentConfig.EnsAPIs = strings.Split(ensapi, ",")
|
currentConfig.EnsAPIs = strings.Split(ensapi, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ensaddr := os.Getenv(SWARM_ENV_ENS_ADDR); ensaddr != "" {
|
if ensaddr := os.Getenv(SwarmEnvENSAddr); ensaddr != "" {
|
||||||
currentConfig.EnsRoot = common.HexToAddress(ensaddr)
|
currentConfig.EnsRoot = common.HexToAddress(ensaddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cors := os.Getenv(SWARM_ENV_CORS); cors != "" {
|
if cors := os.Getenv(SwarmEnvCORS); cors != "" {
|
||||||
currentConfig.Cors = cors
|
currentConfig.Cors = cors
|
||||||
}
|
}
|
||||||
|
|
||||||
if bm := os.Getenv(SWARM_ENV_BOOTNODE_MODE); bm != "" {
|
if bm := os.Getenv(SwarmEnvBootnodeMode); bm != "" {
|
||||||
bootnodeMode, err := strconv.ParseBool(bm)
|
bootnodeMode, err := strconv.ParseBool(bm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_ENV_BOOTNODE_MODE, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmEnvBootnodeMode, err)
|
||||||
}
|
}
|
||||||
currentConfig.BootnodeMode = bootnodeMode
|
currentConfig.BootnodeMode = bootnodeMode
|
||||||
}
|
}
|
||||||
|
|
||||||
if api := os.Getenv(SWARM_GLOBALSTORE_API); api != "" {
|
if api := os.Getenv(SwarmGlobalstoreAPI); api != "" {
|
||||||
currentConfig.GlobalStoreAPI = api
|
currentConfig.GlobalStoreAPI = api
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ func TestConfigFailsSwapEnabledNoSwapApi(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
swarm := runSwarm(t, flags...)
|
swarm := runSwarm(t, flags...)
|
||||||
swarm.Expect("Fatal: " + SWARM_ERR_SWAP_SET_NO_API + "\n")
|
swarm.Expect("Fatal: " + SwarmErrSwapSetNoAPI + "\n")
|
||||||
swarm.ExpectExit()
|
swarm.ExpectExit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ func TestConfigFailsNoBzzAccount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
swarm := runSwarm(t, flags...)
|
swarm := runSwarm(t, flags...)
|
||||||
swarm.Expect("Fatal: " + SWARM_ERR_NO_BZZACCOUNT + "\n")
|
swarm.Expect("Fatal: " + SwarmErrNoBZZAccount + "\n")
|
||||||
swarm.ExpectExit()
|
swarm.ExpectExit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,68 +23,68 @@ var (
|
|||||||
ChequebookAddrFlag = cli.StringFlag{
|
ChequebookAddrFlag = cli.StringFlag{
|
||||||
Name: "chequebook",
|
Name: "chequebook",
|
||||||
Usage: "chequebook contract address",
|
Usage: "chequebook contract address",
|
||||||
EnvVar: SWARM_ENV_CHEQUEBOOK_ADDR,
|
EnvVar: SwarmEnvChequebookAddr,
|
||||||
}
|
}
|
||||||
SwarmAccountFlag = cli.StringFlag{
|
SwarmAccountFlag = cli.StringFlag{
|
||||||
Name: "bzzaccount",
|
Name: "bzzaccount",
|
||||||
Usage: "Swarm account key file",
|
Usage: "Swarm account key file",
|
||||||
EnvVar: SWARM_ENV_ACCOUNT,
|
EnvVar: SwarmEnvAccount,
|
||||||
}
|
}
|
||||||
SwarmListenAddrFlag = cli.StringFlag{
|
SwarmListenAddrFlag = cli.StringFlag{
|
||||||
Name: "httpaddr",
|
Name: "httpaddr",
|
||||||
Usage: "Swarm HTTP API listening interface",
|
Usage: "Swarm HTTP API listening interface",
|
||||||
EnvVar: SWARM_ENV_LISTEN_ADDR,
|
EnvVar: SwarmEnvListenAddr,
|
||||||
}
|
}
|
||||||
SwarmPortFlag = cli.StringFlag{
|
SwarmPortFlag = cli.StringFlag{
|
||||||
Name: "bzzport",
|
Name: "bzzport",
|
||||||
Usage: "Swarm local http api port",
|
Usage: "Swarm local http api port",
|
||||||
EnvVar: SWARM_ENV_PORT,
|
EnvVar: SwarmEnvPort,
|
||||||
}
|
}
|
||||||
SwarmNetworkIdFlag = cli.IntFlag{
|
SwarmNetworkIdFlag = cli.IntFlag{
|
||||||
Name: "bzznetworkid",
|
Name: "bzznetworkid",
|
||||||
Usage: "Network identifier (integer, default 3=swarm testnet)",
|
Usage: "Network identifier (integer, default 3=swarm testnet)",
|
||||||
EnvVar: SWARM_ENV_NETWORK_ID,
|
EnvVar: SwarmEnvNetworkID,
|
||||||
}
|
}
|
||||||
SwarmSwapEnabledFlag = cli.BoolFlag{
|
SwarmSwapEnabledFlag = cli.BoolFlag{
|
||||||
Name: "swap",
|
Name: "swap",
|
||||||
Usage: "Swarm SWAP enabled (default false)",
|
Usage: "Swarm SWAP enabled (default false)",
|
||||||
EnvVar: SWARM_ENV_SWAP_ENABLE,
|
EnvVar: SwarmEnvSwapEnable,
|
||||||
}
|
}
|
||||||
SwarmSwapAPIFlag = cli.StringFlag{
|
SwarmSwapAPIFlag = cli.StringFlag{
|
||||||
Name: "swap-api",
|
Name: "swap-api",
|
||||||
Usage: "URL of the Ethereum API provider to use to settle SWAP payments",
|
Usage: "URL of the Ethereum API provider to use to settle SWAP payments",
|
||||||
EnvVar: SWARM_ENV_SWAP_API,
|
EnvVar: SwarmEnvSwapAPI,
|
||||||
}
|
}
|
||||||
SwarmSyncDisabledFlag = cli.BoolTFlag{
|
SwarmSyncDisabledFlag = cli.BoolTFlag{
|
||||||
Name: "nosync",
|
Name: "nosync",
|
||||||
Usage: "Disable swarm syncing",
|
Usage: "Disable swarm syncing",
|
||||||
EnvVar: SWARM_ENV_SYNC_DISABLE,
|
EnvVar: SwarmEnvSyncDisable,
|
||||||
}
|
}
|
||||||
SwarmSyncUpdateDelay = cli.DurationFlag{
|
SwarmSyncUpdateDelay = cli.DurationFlag{
|
||||||
Name: "sync-update-delay",
|
Name: "sync-update-delay",
|
||||||
Usage: "Duration for sync subscriptions update after no new peers are added (default 15s)",
|
Usage: "Duration for sync subscriptions update after no new peers are added (default 15s)",
|
||||||
EnvVar: SWARM_ENV_SYNC_UPDATE_DELAY,
|
EnvVar: SwarmEnvSyncUpdateDelay,
|
||||||
}
|
}
|
||||||
SwarmMaxStreamPeerServersFlag = cli.IntFlag{
|
SwarmMaxStreamPeerServersFlag = cli.IntFlag{
|
||||||
Name: "max-stream-peer-servers",
|
Name: "max-stream-peer-servers",
|
||||||
Usage: "Limit of Stream peer servers, 0 denotes unlimited",
|
Usage: "Limit of Stream peer servers, 0 denotes unlimited",
|
||||||
EnvVar: SWARM_ENV_MAX_STREAM_PEER_SERVERS,
|
EnvVar: SwarmEnvMaxStreamPeerServers,
|
||||||
Value: 10000, // A very large default value is possible as stream servers have very small memory footprint
|
Value: 10000, // A very large default value is possible as stream servers have very small memory footprint
|
||||||
}
|
}
|
||||||
SwarmLightNodeEnabled = cli.BoolFlag{
|
SwarmLightNodeEnabled = cli.BoolFlag{
|
||||||
Name: "lightnode",
|
Name: "lightnode",
|
||||||
Usage: "Enable Swarm LightNode (default false)",
|
Usage: "Enable Swarm LightNode (default false)",
|
||||||
EnvVar: SWARM_ENV_LIGHT_NODE_ENABLE,
|
EnvVar: SwarmEnvLightNodeEnable,
|
||||||
}
|
}
|
||||||
SwarmDeliverySkipCheckFlag = cli.BoolFlag{
|
SwarmDeliverySkipCheckFlag = cli.BoolFlag{
|
||||||
Name: "delivery-skip-check",
|
Name: "delivery-skip-check",
|
||||||
Usage: "Skip chunk delivery check (default false)",
|
Usage: "Skip chunk delivery check (default false)",
|
||||||
EnvVar: SWARM_ENV_DELIVERY_SKIP_CHECK,
|
EnvVar: SwarmEnvDeliverySkipCheck,
|
||||||
}
|
}
|
||||||
EnsAPIFlag = cli.StringSliceFlag{
|
EnsAPIFlag = cli.StringSliceFlag{
|
||||||
Name: "ens-api",
|
Name: "ens-api",
|
||||||
Usage: "ENS API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url",
|
Usage: "ENS API endpoint for a TLD and with contract address, can be repeated, format [tld:][contract-addr@]url",
|
||||||
EnvVar: SWARM_ENV_ENS_API,
|
EnvVar: SwarmEnvENSAPI,
|
||||||
}
|
}
|
||||||
SwarmApiFlag = cli.StringFlag{
|
SwarmApiFlag = cli.StringFlag{
|
||||||
Name: "bzzapi",
|
Name: "bzzapi",
|
||||||
@ -126,7 +126,7 @@ var (
|
|||||||
SwarmAccessPasswordFlag = cli.StringFlag{
|
SwarmAccessPasswordFlag = cli.StringFlag{
|
||||||
Name: "password",
|
Name: "password",
|
||||||
Usage: "Password",
|
Usage: "Password",
|
||||||
EnvVar: SWARM_ACCESS_PASSWORD,
|
EnvVar: SwarmAccessPassword,
|
||||||
}
|
}
|
||||||
SwarmDryRunFlag = cli.BoolFlag{
|
SwarmDryRunFlag = cli.BoolFlag{
|
||||||
Name: "dry-run",
|
Name: "dry-run",
|
||||||
@ -135,22 +135,22 @@ var (
|
|||||||
CorsStringFlag = cli.StringFlag{
|
CorsStringFlag = cli.StringFlag{
|
||||||
Name: "corsdomain",
|
Name: "corsdomain",
|
||||||
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: SwarmEnvCORS,
|
||||||
}
|
}
|
||||||
SwarmStorePath = cli.StringFlag{
|
SwarmStorePath = cli.StringFlag{
|
||||||
Name: "store.path",
|
Name: "store.path",
|
||||||
Usage: "Path to leveldb chunk DB (default <$GETH_ENV_DIR>/swarm/bzz-<$BZZ_KEY>/chunks)",
|
Usage: "Path to leveldb chunk DB (default <$GETH_ENV_DIR>/swarm/bzz-<$BZZ_KEY>/chunks)",
|
||||||
EnvVar: SWARM_ENV_STORE_PATH,
|
EnvVar: SwarmEnvStorePath,
|
||||||
}
|
}
|
||||||
SwarmStoreCapacity = cli.Uint64Flag{
|
SwarmStoreCapacity = cli.Uint64Flag{
|
||||||
Name: "store.size",
|
Name: "store.size",
|
||||||
Usage: "Number of chunks (5M is roughly 20-25GB) (default 5000000)",
|
Usage: "Number of chunks (5M is roughly 20-25GB) (default 5000000)",
|
||||||
EnvVar: SWARM_ENV_STORE_CAPACITY,
|
EnvVar: SwarmEnvStoreCapacity,
|
||||||
}
|
}
|
||||||
SwarmStoreCacheCapacity = cli.UintFlag{
|
SwarmStoreCacheCapacity = cli.UintFlag{
|
||||||
Name: "store.cache.size",
|
Name: "store.cache.size",
|
||||||
Usage: "Number of recent chunks cached in memory (default 5000)",
|
Usage: "Number of recent chunks cached in memory (default 5000)",
|
||||||
EnvVar: SWARM_ENV_STORE_CACHE_CAPACITY,
|
EnvVar: SwarmEnvStoreCacheCapacity,
|
||||||
}
|
}
|
||||||
SwarmCompressedFlag = cli.BoolFlag{
|
SwarmCompressedFlag = cli.BoolFlag{
|
||||||
Name: "compressed",
|
Name: "compressed",
|
||||||
@ -179,6 +179,6 @@ var (
|
|||||||
SwarmGlobalStoreAPIFlag = cli.StringFlag{
|
SwarmGlobalStoreAPIFlag = cli.StringFlag{
|
||||||
Name: "globalstore-api",
|
Name: "globalstore-api",
|
||||||
Usage: "URL of the Global Store API provider (only for testing)",
|
Usage: "URL of the Global Store API provider (only for testing)",
|
||||||
EnvVar: SWARM_GLOBALSTORE_API,
|
EnvVar: SwarmGlobalstoreAPI,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -76,8 +76,8 @@ var gitCommit string
|
|||||||
|
|
||||||
//declare a few constant error messages, useful for later error check comparisons in test
|
//declare a few constant error messages, useful for later error check comparisons in test
|
||||||
var (
|
var (
|
||||||
SWARM_ERR_NO_BZZACCOUNT = "bzzaccount option is required but not set; check your config file, command line or environment variables"
|
SwarmErrNoBZZAccount = "bzzaccount option is required but not set; check your config file, command line or environment variables"
|
||||||
SWARM_ERR_SWAP_SET_NO_API = "SWAP is enabled but --swap-api is not set"
|
SwarmErrSwapSetNoAPI = "SWAP is enabled but --swap-api is not set"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this help command gets added to any subcommand that does not define it explicitly
|
// this help command gets added to any subcommand that does not define it explicitly
|
||||||
@ -351,7 +351,7 @@ func registerBzzService(bzzconfig *bzzapi.Config, stack *node.Node) {
|
|||||||
func getAccount(bzzaccount string, ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
|
func getAccount(bzzaccount string, ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
|
||||||
//an account is mandatory
|
//an account is mandatory
|
||||||
if bzzaccount == "" {
|
if bzzaccount == "" {
|
||||||
utils.Fatalf(SWARM_ERR_NO_BZZACCOUNT)
|
utils.Fatalf(SwarmErrNoBZZAccount)
|
||||||
}
|
}
|
||||||
// Try to load the arg as a hex key file.
|
// Try to load the arg as a hex key file.
|
||||||
if key, err := crypto.LoadECDSA(bzzaccount); err == nil {
|
if key, err := crypto.LoadECDSA(bzzaccount); err == nil {
|
||||||
|
@ -60,10 +60,10 @@ func upload(ctx *cli.Context) {
|
|||||||
autoDefaultPath = false
|
autoDefaultPath = false
|
||||||
file string
|
file string
|
||||||
)
|
)
|
||||||
if autoDefaultPathString := os.Getenv(SWARM_AUTO_DEFAULTPATH); autoDefaultPathString != "" {
|
if autoDefaultPathString := os.Getenv(SwarmAutoDefaultPath); autoDefaultPathString != "" {
|
||||||
b, err := strconv.ParseBool(autoDefaultPathString)
|
b, err := strconv.ParseBool(autoDefaultPathString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("invalid environment variable %s: %v", SWARM_AUTO_DEFAULTPATH, err)
|
utils.Fatalf("invalid environment variable %s: %v", SwarmAutoDefaultPath, err)
|
||||||
}
|
}
|
||||||
autoDefaultPath = b
|
autoDefaultPath = b
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const EMPTY_CREDENTIALS = ""
|
const EmptyCredentials = ""
|
||||||
|
|
||||||
type AccessEntry struct {
|
type AccessEntry struct {
|
||||||
Type AccessType
|
Type AccessType
|
||||||
|
@ -431,7 +431,7 @@ func (a *API) Delete(ctx context.Context, addr string, path string) (storage.Add
|
|||||||
apiDeleteFail.Inc(1)
|
apiDeleteFail.Inc(1)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
key, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
key, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -643,7 +643,7 @@ func (a *API) AddFile(ctx context.Context, mhash, path, fname string, content []
|
|||||||
apiAddFileFail.Inc(1)
|
apiAddFileFail.Inc(1)
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
mkey, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
mkey, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiAddFileFail.Inc(1)
|
apiAddFileFail.Inc(1)
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
@ -760,7 +760,7 @@ func (a *API) RemoveFile(ctx context.Context, mhash string, path string, fname s
|
|||||||
apiRmFileFail.Inc(1)
|
apiRmFileFail.Inc(1)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
mkey, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
mkey, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiRmFileFail.Inc(1)
|
apiRmFileFail.Inc(1)
|
||||||
return "", err
|
return "", err
|
||||||
@ -827,7 +827,7 @@ func (a *API) AppendFile(ctx context.Context, mhash, path, fname string, existin
|
|||||||
apiAppendFileFail.Inc(1)
|
apiAppendFileFail.Inc(1)
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
mkey, err := a.ResolveURI(ctx, uri, EMPTY_CREDENTIALS)
|
mkey, err := a.ResolveURI(ctx, uri, EmptyCredentials)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiAppendFileFail.Inc(1)
|
apiAppendFileFail.Inc(1)
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Swarmfs_Version = "0.1"
|
SwarmFSVersion = "0.1"
|
||||||
mountTimeout = time.Second * 5
|
mountTimeout = time.Second * 5
|
||||||
unmountTimeout = time.Second * 10
|
unmountTimeout = time.Second * 10
|
||||||
maxFuseMounts = 5
|
maxFUSEMounts = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -96,7 +96,7 @@ func (swarmfs *SwarmFS) Mount(mhash, mountpoint string) (*MountInfo, error) {
|
|||||||
|
|
||||||
noOfActiveMounts := len(swarmfs.activeMounts)
|
noOfActiveMounts := len(swarmfs.activeMounts)
|
||||||
log.Debug("swarmfs mount", "# active mounts", noOfActiveMounts)
|
log.Debug("swarmfs mount", "# active mounts", noOfActiveMounts)
|
||||||
if noOfActiveMounts >= maxFuseMounts {
|
if noOfActiveMounts >= maxFUSEMounts {
|
||||||
return nil, errMaxMountCount
|
return nil, errMaxMountCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,20 +101,20 @@ func NewPeer(peer *protocols.Peer, streamer *Registry) *Peer {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
var len_maxi int
|
var lenMaxi int
|
||||||
var cap_maxi int
|
var capMaxi int
|
||||||
for k := range pq.Queues {
|
for k := range pq.Queues {
|
||||||
if len_maxi < len(pq.Queues[k]) {
|
if lenMaxi < len(pq.Queues[k]) {
|
||||||
len_maxi = len(pq.Queues[k])
|
lenMaxi = len(pq.Queues[k])
|
||||||
}
|
}
|
||||||
|
|
||||||
if cap_maxi < cap(pq.Queues[k]) {
|
if capMaxi < cap(pq.Queues[k]) {
|
||||||
cap_maxi = cap(pq.Queues[k])
|
capMaxi = cap(pq.Queues[k])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_len_%s", p.ID().TerminalString()), nil).Update(int64(len_maxi))
|
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_len_%s", p.ID().TerminalString()), nil).Update(int64(lenMaxi))
|
||||||
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_cap_%s", p.ID().TerminalString()), nil).Update(int64(cap_maxi))
|
metrics.GetOrRegisterGauge(fmt.Sprintf("pq_cap_%s", p.ID().TerminalString()), nil).Update(int64(capMaxi))
|
||||||
case <-p.quit:
|
case <-p.quit:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ func testIterator(t *testing.T, mock bool) {
|
|||||||
var i int
|
var i int
|
||||||
var poc uint
|
var poc uint
|
||||||
chunkkeys := NewAddressCollection(chunkcount)
|
chunkkeys := NewAddressCollection(chunkcount)
|
||||||
chunkkeys_results := NewAddressCollection(chunkcount)
|
chunkkeysResults := NewAddressCollection(chunkcount)
|
||||||
|
|
||||||
db, cleanup, err := newTestDbStore(mock, false)
|
db, cleanup, err := newTestDbStore(mock, false)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
@ -218,7 +218,7 @@ func testIterator(t *testing.T, mock bool) {
|
|||||||
for poc = 0; poc <= 255; poc++ {
|
for poc = 0; poc <= 255; poc++ {
|
||||||
err := db.SyncIterator(0, uint64(chunkkeys.Len()), uint8(poc), func(k Address, n uint64) bool {
|
err := db.SyncIterator(0, uint64(chunkkeys.Len()), uint8(poc), func(k Address, n uint64) bool {
|
||||||
log.Trace(fmt.Sprintf("Got key %v number %d poc %d", k, n, uint8(poc)))
|
log.Trace(fmt.Sprintf("Got key %v number %d poc %d", k, n, uint8(poc)))
|
||||||
chunkkeys_results[n] = k
|
chunkkeysResults[n] = k
|
||||||
i++
|
i++
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -228,8 +228,8 @@ func testIterator(t *testing.T, mock bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i = 0; i < chunkcount; i++ {
|
for i = 0; i < chunkcount; i++ {
|
||||||
if !bytes.Equal(chunkkeys[i], chunkkeys_results[i]) {
|
if !bytes.Equal(chunkkeys[i], chunkkeysResults[i]) {
|
||||||
t.Fatalf("Chunk put #%d key '%v' does not match iterator's key '%v'", i, chunkkeys[i], chunkkeys_results[i])
|
t.Fatalf("Chunk put #%d key '%v' does not match iterator's key '%v'", i, chunkkeys[i], chunkkeysResults[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ func (s *Swarm) APIs() []rpc.API {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Namespace: "swarmfs",
|
Namespace: "swarmfs",
|
||||||
Version: fuse.Swarmfs_Version,
|
Version: fuse.SwarmFSVersion,
|
||||||
Service: s.sfs,
|
Service: s.sfs,
|
||||||
Public: false,
|
Public: false,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user