Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions cmd/XDC/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"os"
"runtime"
"slices"
"strconv"
"sync/atomic"
"time"
Expand All @@ -41,13 +42,7 @@ var (
Name: "init",
Usage: "Bootstrap and initialize a new genesis block",
ArgsUsage: "<genesisPath>",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.XDCXDataDirFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
},
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
Description: `
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
Expand All @@ -60,9 +55,7 @@ It expects the genesis file or the network name [ mainnet | testnet | devnet ] a
Name: "import",
Usage: "Import a blockchain file",
ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.XDCXDataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
utils.GCModeFlag,
Expand All @@ -80,7 +73,7 @@ It expects the genesis file or the network name [ mainnet | testnet | devnet ] a
utils.MetricsInfluxDBTokenFlag,
utils.MetricsInfluxDBBucketFlag,
utils.MetricsInfluxDBOrganizationFlag,
},
}, utils.DatabaseFlags),
Description: `
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.
Expand All @@ -93,12 +86,10 @@ processing will proceed even if an individual RLP-file import failure occurs.`,
Name: "export",
Usage: "Export blockchain into file",
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.XDCXDataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
},
}, utils.DatabaseFlags),
Description: `
Requires a first argument of the file to write to.
Optional second and third arguments control the first and
Expand All @@ -110,12 +101,10 @@ if already existing.`,
Name: "import-preimages",
Usage: "Import the preimage database from an RLP stream",
ArgsUsage: "<datafile>",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.XDCXDataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
},
}, utils.DatabaseFlags),
Category: "BLOCKCHAIN COMMANDS",
Description: `
The import-preimages command imports hash preimages from an RLP encoded stream.`,
Expand All @@ -125,12 +114,10 @@ if already existing.`,
Name: "export-preimages",
Usage: "Export the preimage database into an RLP stream",
ArgsUsage: "<dumpfile>",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.XDCXDataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
},
}, utils.DatabaseFlags),
Description: `
The export-preimages command export hash preimages to an RLP encoded stream`,
}
Expand All @@ -139,12 +126,10 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
Name: "dump",
Usage: "Dump a specific block from storage",
ArgsUsage: "[<blockHash> | <blockNum>]...",
Flags: []cli.Flag{
utils.DataDirFlag,
utils.XDCXDataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.CacheFlag,
utils.SyncModeFlag,
},
}, utils.DatabaseFlags),
Category: "BLOCKCHAIN COMMANDS",
Description: `
The arguments are interpreted as block numbers or hashes.
Expand Down
53 changes: 14 additions & 39 deletions cmd/XDC/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"time"

"github.com/XinFinOrg/XDPoSChain/cmd/utils"
Expand All @@ -38,9 +39,7 @@ var (
Name: "removedb",
Usage: "Remove blockchain and state databases",
ArgsUsage: " ",
Flags: []cli.Flag{
utils.DataDirFlag,
},
Flags: utils.DatabaseFlags,
Description: `
Remove blockchain and state databases`,
}
Expand All @@ -61,41 +60,29 @@ Remove blockchain and state databases`,
Action: inspect,
Name: "inspect",
ArgsUsage: "<prefix> <start>",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.SyncModeFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
},
}, utils.NetworkFlags, utils.DatabaseFlags),
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.`,
}
dbStatCmd = &cli.Command{
Action: dbStats,
Name: "stats",
Usage: "Print leveldb statistics",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.SyncModeFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
},
}, utils.NetworkFlags, utils.DatabaseFlags),
}
dbCompactCmd = &cli.Command{
Action: dbCompact,
Name: "compact",
Usage: "Compact leveldb database. WARNING: May take a very long time",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.SyncModeFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
},
}, utils.NetworkFlags, utils.DatabaseFlags),
Description: `This command performs a database compaction.
WARNING: This operation may take a very long time to finish, and may cause database
corruption if it is aborted during execution'!`,
Expand All @@ -105,27 +92,19 @@ corruption if it is aborted during execution'!`,
Name: "get",
Usage: "Show the value of a database key",
ArgsUsage: "<hex-encoded key>",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.SyncModeFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
},
}, utils.NetworkFlags, utils.DatabaseFlags),
Description: "This command looks up the specified database key from the database.",
}
dbDeleteCmd = &cli.Command{
Action: dbDelete,
Name: "delete",
Usage: "Delete a database key (WARNING: may corrupt your database)",
ArgsUsage: "<hex-encoded key>",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.SyncModeFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
},
}, utils.NetworkFlags, utils.DatabaseFlags),
Description: `This command deletes the specified database key from the database.
WARNING: This is a low-level operation which may cause database corruption!`,
}
Expand All @@ -134,13 +113,9 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name: "put",
Usage: "Set the value of a database key (WARNING: may corrupt your database)",
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
Flags: []cli.Flag{
utils.DataDirFlag,
Flags: slices.Concat([]cli.Flag{
utils.SyncModeFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
},
}, utils.NetworkFlags, utils.DatabaseFlags),
Description: `This command sets a given database key to the given value.
WARNING: This is a low-level operation which may cause database corruption!`,
}
Expand Down
13 changes: 5 additions & 8 deletions cmd/XDC/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"runtime"
"slices"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -52,15 +53,15 @@ var (
gitCommit = ""
// The app that holds all commands and flags.
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.UnlockedAccountFlag,
utils.PasswordFileFlag,
utils.BootnodesFlag,
utils.BootnodesV4Flag,
utils.BootnodesV5Flag,
utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.NoUSBFlag, // deprecated
utils.USBFlag,
Expand All @@ -72,7 +73,6 @@ var (
//utils.EthashDatasetsInMemoryFlag,
//utils.EthashDatasetsOnDiskFlag,
utils.XDCXEnabledFlag,
utils.XDCXDataDirFlag,
utils.XDCXDBEngineFlag,
utils.XDCXDBConnectionUrlFlag,
utils.XDCXDBReplicaSetNameFlag,
Expand Down Expand Up @@ -115,9 +115,6 @@ var (
utils.NodeKeyHexFlag,
//utils.DeveloperFlag,
//utils.DeveloperPeriodFlag,
utils.MainnetFlag,
utils.TestnetFlag,
utils.DevnetFlag,
//utils.VMEnableDebugFlag,
utils.Enable0xPrefixFlag,
utils.EnableXDCPrefixFlag,
Expand All @@ -139,7 +136,7 @@ var (
utils.StoreRewardFlag,
utils.SetHeadFlag,
utils.XDCSlaveModeFlag,
}
}, utils.NetworkFlags, utils.DatabaseFlags)

rpcFlags = []cli.Flag{
utils.HTTPEnabledFlag,
Expand Down
15 changes: 15 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// 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.
Expand Down