mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
Merge pull request #921 from gzliudan/group-net-db-flags
cmd: group network and database flags together
This commit is contained in:
commit
b7eeb0d939
4 changed files with 46 additions and 74 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -41,13 +42,7 @@ var (
|
||||||
Name: "init",
|
Name: "init",
|
||||||
Usage: "Bootstrap and initialize a new genesis block",
|
Usage: "Bootstrap and initialize a new genesis block",
|
||||||
ArgsUsage: "<genesisPath>",
|
ArgsUsage: "<genesisPath>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.MainnetFlag,
|
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
},
|
|
||||||
Description: `
|
Description: `
|
||||||
The init command initializes a new genesis block and definition for the network.
|
The init command initializes a new genesis block and definition for the network.
|
||||||
This is a destructive action and changes the network in which you will be
|
This is a destructive action and changes the network in which you will be
|
||||||
|
|
@ -60,9 +55,7 @@ It expects the genesis file or the network name [ mainnet | testnet | devnet ] a
|
||||||
Name: "import",
|
Name: "import",
|
||||||
Usage: "Import a blockchain file",
|
Usage: "Import a blockchain file",
|
||||||
ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
|
ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.GCModeFlag,
|
utils.GCModeFlag,
|
||||||
|
|
@ -80,7 +73,7 @@ It expects the genesis file or the network name [ mainnet | testnet | devnet ] a
|
||||||
utils.MetricsInfluxDBTokenFlag,
|
utils.MetricsInfluxDBTokenFlag,
|
||||||
utils.MetricsInfluxDBBucketFlag,
|
utils.MetricsInfluxDBBucketFlag,
|
||||||
utils.MetricsInfluxDBOrganizationFlag,
|
utils.MetricsInfluxDBOrganizationFlag,
|
||||||
},
|
}, utils.DatabaseFlags),
|
||||||
Description: `
|
Description: `
|
||||||
The import command imports blocks from an RLP-encoded form. The form can be one file
|
The import command imports blocks from an RLP-encoded form. The form can be one file
|
||||||
with several RLP-encoded blocks, or several files can be used.
|
with several RLP-encoded blocks, or several files can be used.
|
||||||
|
|
@ -93,12 +86,10 @@ processing will proceed even if an individual RLP-file import failure occurs.`,
|
||||||
Name: "export",
|
Name: "export",
|
||||||
Usage: "Export blockchain into file",
|
Usage: "Export blockchain into file",
|
||||||
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
|
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
}, utils.DatabaseFlags),
|
||||||
Description: `
|
Description: `
|
||||||
Requires a first argument of the file to write to.
|
Requires a first argument of the file to write to.
|
||||||
Optional second and third arguments control the first and
|
Optional second and third arguments control the first and
|
||||||
|
|
@ -110,12 +101,10 @@ if already existing.`,
|
||||||
Name: "import-preimages",
|
Name: "import-preimages",
|
||||||
Usage: "Import the preimage database from an RLP stream",
|
Usage: "Import the preimage database from an RLP stream",
|
||||||
ArgsUsage: "<datafile>",
|
ArgsUsage: "<datafile>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
}, utils.DatabaseFlags),
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
The import-preimages command imports hash preimages from an RLP encoded stream.`,
|
The import-preimages command imports hash preimages from an RLP encoded stream.`,
|
||||||
|
|
@ -125,12 +114,10 @@ if already existing.`,
|
||||||
Name: "export-preimages",
|
Name: "export-preimages",
|
||||||
Usage: "Export the preimage database into an RLP stream",
|
Usage: "Export the preimage database into an RLP stream",
|
||||||
ArgsUsage: "<dumpfile>",
|
ArgsUsage: "<dumpfile>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
}, utils.DatabaseFlags),
|
||||||
Description: `
|
Description: `
|
||||||
The export-preimages command export hash preimages to an RLP encoded stream`,
|
The export-preimages command export hash preimages to an RLP encoded stream`,
|
||||||
}
|
}
|
||||||
|
|
@ -139,12 +126,10 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
|
||||||
Name: "dump",
|
Name: "dump",
|
||||||
Usage: "Dump a specific block from storage",
|
Usage: "Dump a specific block from storage",
|
||||||
ArgsUsage: "[<blockHash> | <blockNum>]...",
|
ArgsUsage: "[<blockHash> | <blockNum>]...",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
},
|
}, utils.DatabaseFlags),
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
Category: "BLOCKCHAIN COMMANDS",
|
||||||
Description: `
|
Description: `
|
||||||
The arguments are interpreted as block numbers or hashes.
|
The arguments are interpreted as block numbers or hashes.
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/cmd/utils"
|
"github.com/XinFinOrg/XDPoSChain/cmd/utils"
|
||||||
|
|
@ -38,9 +39,7 @@ var (
|
||||||
Name: "removedb",
|
Name: "removedb",
|
||||||
Usage: "Remove blockchain and state databases",
|
Usage: "Remove blockchain and state databases",
|
||||||
ArgsUsage: " ",
|
ArgsUsage: " ",
|
||||||
Flags: []cli.Flag{
|
Flags: utils.DatabaseFlags,
|
||||||
utils.DataDirFlag,
|
|
||||||
},
|
|
||||||
Description: `
|
Description: `
|
||||||
Remove blockchain and state databases`,
|
Remove blockchain and state databases`,
|
||||||
}
|
}
|
||||||
|
|
@ -61,13 +60,9 @@ Remove blockchain and state databases`,
|
||||||
Action: inspect,
|
Action: inspect,
|
||||||
Name: "inspect",
|
Name: "inspect",
|
||||||
ArgsUsage: "<prefix> <start>",
|
ArgsUsage: "<prefix> <start>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.MainnetFlag,
|
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
},
|
|
||||||
Usage: "Inspect the storage size for each type of data in the database",
|
Usage: "Inspect the storage size for each type of data in the database",
|
||||||
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
|
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
|
||||||
}
|
}
|
||||||
|
|
@ -75,27 +70,19 @@ Remove blockchain and state databases`,
|
||||||
Action: dbStats,
|
Action: dbStats,
|
||||||
Name: "stats",
|
Name: "stats",
|
||||||
Usage: "Print leveldb statistics",
|
Usage: "Print leveldb statistics",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.MainnetFlag,
|
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
dbCompactCmd = &cli.Command{
|
dbCompactCmd = &cli.Command{
|
||||||
Action: dbCompact,
|
Action: dbCompact,
|
||||||
Name: "compact",
|
Name: "compact",
|
||||||
Usage: "Compact leveldb database. WARNING: May take a very long time",
|
Usage: "Compact leveldb database. WARNING: May take a very long time",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.MainnetFlag,
|
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
utils.CacheFlag,
|
utils.CacheFlag,
|
||||||
utils.CacheDatabaseFlag,
|
utils.CacheDatabaseFlag,
|
||||||
},
|
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
Description: `This command performs a database compaction.
|
Description: `This command performs a database compaction.
|
||||||
WARNING: This operation may take a very long time to finish, and may cause database
|
WARNING: This operation may take a very long time to finish, and may cause database
|
||||||
corruption if it is aborted during execution'!`,
|
corruption if it is aborted during execution'!`,
|
||||||
|
|
@ -105,13 +92,9 @@ corruption if it is aborted during execution'!`,
|
||||||
Name: "get",
|
Name: "get",
|
||||||
Usage: "Show the value of a database key",
|
Usage: "Show the value of a database key",
|
||||||
ArgsUsage: "<hex-encoded key>",
|
ArgsUsage: "<hex-encoded key>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.MainnetFlag,
|
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
},
|
|
||||||
Description: "This command looks up the specified database key from the database.",
|
Description: "This command looks up the specified database key from the database.",
|
||||||
}
|
}
|
||||||
dbDeleteCmd = &cli.Command{
|
dbDeleteCmd = &cli.Command{
|
||||||
|
|
@ -119,13 +102,9 @@ corruption if it is aborted during execution'!`,
|
||||||
Name: "delete",
|
Name: "delete",
|
||||||
Usage: "Delete a database key (WARNING: may corrupt your database)",
|
Usage: "Delete a database key (WARNING: may corrupt your database)",
|
||||||
ArgsUsage: "<hex-encoded key>",
|
ArgsUsage: "<hex-encoded key>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.MainnetFlag,
|
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
},
|
|
||||||
Description: `This command deletes the specified database key from the database.
|
Description: `This command deletes the specified database key from the database.
|
||||||
WARNING: This is a low-level operation which may cause database corruption!`,
|
WARNING: This is a low-level operation which may cause database corruption!`,
|
||||||
}
|
}
|
||||||
|
|
@ -134,13 +113,9 @@ WARNING: This is a low-level operation which may cause database corruption!`,
|
||||||
Name: "put",
|
Name: "put",
|
||||||
Usage: "Set the value of a database key (WARNING: may corrupt your database)",
|
Usage: "Set the value of a database key (WARNING: may corrupt your database)",
|
||||||
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
|
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
|
||||||
Flags: []cli.Flag{
|
Flags: slices.Concat([]cli.Flag{
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.SyncModeFlag,
|
utils.SyncModeFlag,
|
||||||
utils.MainnetFlag,
|
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
},
|
|
||||||
Description: `This command sets a given database key to the given value.
|
Description: `This command sets a given database key to the given value.
|
||||||
WARNING: This is a low-level operation which may cause database corruption!`,
|
WARNING: This is a low-level operation which may cause database corruption!`,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -52,15 +53,15 @@ var (
|
||||||
gitCommit = ""
|
gitCommit = ""
|
||||||
// The app that holds all commands and flags.
|
// The app that holds all commands and flags.
|
||||||
app = flags.NewApp(gitCommit, "the XDPoSChain command line interface")
|
app = flags.NewApp(gitCommit, "the XDPoSChain command line interface")
|
||||||
// flags that configure the node
|
|
||||||
nodeFlags = []cli.Flag{
|
// The app that holds all commands and flags.
|
||||||
|
nodeFlags = slices.Concat([]cli.Flag{
|
||||||
utils.IdentityFlag,
|
utils.IdentityFlag,
|
||||||
utils.UnlockedAccountFlag,
|
utils.UnlockedAccountFlag,
|
||||||
utils.PasswordFileFlag,
|
utils.PasswordFileFlag,
|
||||||
utils.BootnodesFlag,
|
utils.BootnodesFlag,
|
||||||
utils.BootnodesV4Flag,
|
utils.BootnodesV4Flag,
|
||||||
utils.BootnodesV5Flag,
|
utils.BootnodesV5Flag,
|
||||||
utils.DataDirFlag,
|
|
||||||
utils.KeyStoreDirFlag,
|
utils.KeyStoreDirFlag,
|
||||||
utils.NoUSBFlag, // deprecated
|
utils.NoUSBFlag, // deprecated
|
||||||
utils.USBFlag,
|
utils.USBFlag,
|
||||||
|
|
@ -72,7 +73,6 @@ var (
|
||||||
//utils.EthashDatasetsInMemoryFlag,
|
//utils.EthashDatasetsInMemoryFlag,
|
||||||
//utils.EthashDatasetsOnDiskFlag,
|
//utils.EthashDatasetsOnDiskFlag,
|
||||||
utils.XDCXEnabledFlag,
|
utils.XDCXEnabledFlag,
|
||||||
utils.XDCXDataDirFlag,
|
|
||||||
utils.XDCXDBEngineFlag,
|
utils.XDCXDBEngineFlag,
|
||||||
utils.XDCXDBConnectionUrlFlag,
|
utils.XDCXDBConnectionUrlFlag,
|
||||||
utils.XDCXDBReplicaSetNameFlag,
|
utils.XDCXDBReplicaSetNameFlag,
|
||||||
|
|
@ -115,9 +115,6 @@ var (
|
||||||
utils.NodeKeyHexFlag,
|
utils.NodeKeyHexFlag,
|
||||||
//utils.DeveloperFlag,
|
//utils.DeveloperFlag,
|
||||||
//utils.DeveloperPeriodFlag,
|
//utils.DeveloperPeriodFlag,
|
||||||
utils.MainnetFlag,
|
|
||||||
utils.TestnetFlag,
|
|
||||||
utils.DevnetFlag,
|
|
||||||
//utils.VMEnableDebugFlag,
|
//utils.VMEnableDebugFlag,
|
||||||
utils.Enable0xPrefixFlag,
|
utils.Enable0xPrefixFlag,
|
||||||
utils.EnableXDCPrefixFlag,
|
utils.EnableXDCPrefixFlag,
|
||||||
|
|
@ -139,7 +136,7 @@ var (
|
||||||
utils.StoreRewardFlag,
|
utils.StoreRewardFlag,
|
||||||
utils.SetHeadFlag,
|
utils.SetHeadFlag,
|
||||||
utils.XDCSlaveModeFlag,
|
utils.XDCSlaveModeFlag,
|
||||||
}
|
}, utils.NetworkFlags, utils.DatabaseFlags)
|
||||||
|
|
||||||
rpcFlags = []cli.Flag{
|
rpcFlags = []cli.Flag{
|
||||||
utils.HTTPEnabledFlag,
|
utils.HTTPEnabledFlag,
|
||||||
|
|
|
||||||
|
|
@ -788,6 +788,21 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// NetworkFlags is the flag group of all built-in supported networks.
|
||||||
|
NetworkFlags = []cli.Flag{
|
||||||
|
MainnetFlag,
|
||||||
|
TestnetFlag,
|
||||||
|
DevnetFlag,
|
||||||
|
}
|
||||||
|
|
||||||
|
// DatabaseFlags is the flag group of all database flags.
|
||||||
|
DatabaseFlags = []cli.Flag{
|
||||||
|
DataDirFlag,
|
||||||
|
XDCXDataDirFlag,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// MakeDataDir retrieves the currently requested data directory, terminating
|
// MakeDataDir retrieves the currently requested data directory, terminating
|
||||||
// if none (or the empty string) is specified. If the node is starting a testnet,
|
// if none (or the empty string) is specified. If the node is starting a testnet,
|
||||||
// the a subdirectory of the specified datadir will be used.
|
// the a subdirectory of the specified datadir will be used.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue