Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
1ed8b7d2
Unverified
Commit
1ed8b7d2
authored
Jul 25, 2022
by
rjl493456442
Committed by
GitHub
Jul 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: use flags.Merge for grouping flags (#25392)
parent
b2be5f95
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
45 deletions
+40
-45
chaincmd.go
cmd/geth/chaincmd.go
+11
-10
config.go
cmd/geth/config.go
+1
-1
consolecmd.go
cmd/geth/consolecmd.go
+4
-3
dbcmd.go
cmd/geth/dbcmd.go
+14
-13
main.go
cmd/geth/main.go
+2
-2
snapshot.go
cmd/geth/snapshot.go
+8
-7
flags.go
cmd/utils/flags.go
+0
-9
No files found.
cmd/geth/chaincmd.go
View file @
1ed8b7d2
...
...
@@ -35,6 +35,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
...
...
@@ -69,7 +70,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
Name
:
"import"
,
Usage
:
"Import a blockchain file"
,
ArgsUsage
:
"<filename> (<filename 2> ... <filename N>) "
,
Flags
:
append
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
CacheFlag
,
utils
.
SyncModeFlag
,
utils
.
GCModeFlag
,
...
...
@@ -91,7 +92,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
utils
.
MetricsInfluxDBBucketFlag
,
utils
.
MetricsInfluxDBOrganizationFlag
,
utils
.
TxLookupLimitFlag
,
},
utils
.
DatabasePathFlags
...
),
},
utils
.
DatabasePathFlags
),
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.
...
...
@@ -104,10 +105,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
:
append
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
CacheFlag
,
utils
.
SyncModeFlag
,
},
utils
.
DatabasePathFlags
...
),
},
utils
.
DatabasePathFlags
),
Description
:
`
Requires a first argument of the file to write to.
Optional second and third arguments control the first and
...
...
@@ -120,10 +121,10 @@ be gzipped.`,
Name
:
"import-preimages"
,
Usage
:
"Import the preimage database from an RLP stream"
,
ArgsUsage
:
"<datafile>"
,
Flags
:
append
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
CacheFlag
,
utils
.
SyncModeFlag
,
},
utils
.
DatabasePathFlags
...
),
},
utils
.
DatabasePathFlags
),
Description
:
`
The import-preimages command imports hash preimages from an RLP encoded stream.
It's deprecated, please use "geth db import" instead.
...
...
@@ -134,10 +135,10 @@ It's deprecated, please use "geth db import" instead.
Name
:
"export-preimages"
,
Usage
:
"Export the preimage database into an RLP stream"
,
ArgsUsage
:
"<dumpfile>"
,
Flags
:
append
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
CacheFlag
,
utils
.
SyncModeFlag
,
},
utils
.
DatabasePathFlags
...
),
},
utils
.
DatabasePathFlags
),
Description
:
`
The export-preimages command exports hash preimages to an RLP encoded stream.
It's deprecated, please use "geth db export" instead.
...
...
@@ -148,7 +149,7 @@ It's deprecated, please use "geth db export" instead.
Name
:
"dump"
,
Usage
:
"Dump a specific block from storage"
,
ArgsUsage
:
"[? <blockHash> | <blockNum>]"
,
Flags
:
append
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
CacheFlag
,
utils
.
IterativeOutputFlag
,
utils
.
ExcludeCodeFlag
,
...
...
@@ -156,7 +157,7 @@ It's deprecated, please use "geth db export" instead.
utils
.
IncludeIncompletesFlag
,
utils
.
StartKeyFlag
,
utils
.
DumpLimitFlag
,
},
utils
.
DatabasePathFlags
...
),
},
utils
.
DatabasePathFlags
),
Description
:
`
This command dumps out the state for a given block (or latest, if none provided).
`
,
...
...
cmd/geth/config.go
View file @
1ed8b7d2
...
...
@@ -49,7 +49,7 @@ var (
Name
:
"dumpconfig"
,
Usage
:
"Show configuration values"
,
ArgsUsage
:
""
,
Flags
:
utils
.
GroupFlags
(
nodeFlags
,
rpcFlags
),
Flags
:
flags
.
Merge
(
nodeFlags
,
rpcFlags
),
Description
:
`The dumpconfig command shows configuration values.`
,
}
...
...
cmd/geth/consolecmd.go
View file @
1ed8b7d2
...
...
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
"github.com/urfave/cli/v2"
...
...
@@ -34,7 +35,7 @@ var (
Action
:
localConsole
,
Name
:
"console"
,
Usage
:
"Start an interactive JavaScript environment"
,
Flags
:
utils
.
GroupFlags
(
nodeFlags
,
rpcFlags
,
consoleFlags
),
Flags
:
flags
.
Merge
(
nodeFlags
,
rpcFlags
,
consoleFlags
),
Description
:
`
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
...
...
@@ -46,7 +47,7 @@ See https://geth.ethereum.org/docs/interface/javascript-console.`,
Name
:
"attach"
,
Usage
:
"Start an interactive JavaScript environment (connect to node)"
,
ArgsUsage
:
"[endpoint]"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
utils
.
DataDirFlag
},
consoleFlags
),
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
DataDirFlag
},
consoleFlags
),
Description
:
`
The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
...
...
@@ -59,7 +60,7 @@ This command allows to open a console on a running geth node.`,
Name
:
"js"
,
Usage
:
"(DEPRECATED) Execute the specified JavaScript files"
,
ArgsUsage
:
"<jsfile> [jsfile...]"
,
Flags
:
utils
.
GroupFlags
(
nodeFlags
,
consoleFlags
),
Flags
:
flags
.
Merge
(
nodeFlags
,
consoleFlags
),
Description
:
`
The JavaScript VM exposes a node admin interface as well as the Ðapp
JavaScript API. See https://geth.ethereum.org/docs/interface/javascript-console`
,
...
...
cmd/geth/dbcmd.go
View file @
1ed8b7d2
...
...
@@ -37,6 +37,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/olekukonko/tablewriter"
...
...
@@ -77,7 +78,7 @@ Remove blockchain and state databases`,
Action
:
inspect
,
Name
:
"inspect"
,
ArgsUsage
:
"<prefix> <start>"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Usage
:
"Inspect the storage size for each type of data in the database"
,
...
...
@@ -87,7 +88,7 @@ Remove blockchain and state databases`,
Action
:
checkStateContent
,
Name
:
"check-state-content"
,
ArgsUsage
:
"<start (optional)>"
,
Flags
:
utils
.
GroupFlags
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Flags
:
flags
.
Merge
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Usage
:
"Verify that state data is cryptographically correct"
,
Description
:
`This command iterates the entire database for 32-byte keys, looking for rlp-encoded trie nodes.
For each trie node encountered, it checks that the key corresponds to the keccak256(value). If this is not true, this indicates
...
...
@@ -97,7 +98,7 @@ a data corruption.`,
Action
:
dbStats
,
Name
:
"stats"
,
Usage
:
"Print leveldb statistics"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
}
...
...
@@ -105,7 +106,7 @@ a data corruption.`,
Action
:
dbCompact
,
Name
:
"compact"
,
Usage
:
"Compact leveldb database. WARNING: May take a very long time"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
utils
.
CacheFlag
,
utils
.
CacheDatabaseFlag
,
...
...
@@ -119,7 +120,7 @@ corruption if it is aborted during execution'!`,
Name
:
"get"
,
Usage
:
"Show the value of a database key"
,
ArgsUsage
:
"<hex-encoded key>"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
"This command looks up the specified database key from the database."
,
...
...
@@ -129,7 +130,7 @@ corruption if it is aborted during execution'!`,
Name
:
"delete"
,
Usage
:
"Delete a database key (WARNING: may corrupt your database)"
,
ArgsUsage
:
"<hex-encoded key>"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`This command deletes the specified database key from the database.
...
...
@@ -140,7 +141,7 @@ 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
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`This command sets a given database key to the given value.
...
...
@@ -151,7 +152,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name
:
"dumptrie"
,
Usage
:
"Show the storage key/values of a given storage trie"
,
ArgsUsage
:
"<hex-encoded storage trie root> <hex-encoded start (optional)> <int max elements (optional)>"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
"This command looks up the specified database key from the database."
,
...
...
@@ -161,7 +162,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name
:
"freezer-index"
,
Usage
:
"Dump out the index of a given freezer type"
,
ArgsUsage
:
"<type> <start (int)> <end (int)>"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
"This command displays information about the freezer index."
,
...
...
@@ -171,7 +172,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name
:
"import"
,
Usage
:
"Imports leveldb-data from an exported RLP dump."
,
ArgsUsage
:
"<dumpfile> <start (optional)"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
"The import command imports the specific chain data from an RLP encoded stream."
,
...
...
@@ -181,7 +182,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name
:
"export"
,
Usage
:
"Exports the chain data into an RLP dump. If the <dumpfile> has .gz suffix, gzip compression will be used."
,
ArgsUsage
:
"<type> <dumpfile>"
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
"Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed."
,
...
...
@@ -190,7 +191,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Action
:
showMetaData
,
Name
:
"metadata"
,
Usage
:
"Shows metadata about the chain status."
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
"Shows metadata about the chain status."
,
...
...
@@ -200,7 +201,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name
:
"freezer-migrate"
,
Usage
:
"Migrate legacy parts of the freezer. (WARNING: may take a long time)"
,
ArgsUsage
:
""
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
SyncModeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`The freezer-migrate command checks your database for receipts in a legacy format and updates those.
...
...
cmd/geth/main.go
View file @
1ed8b7d2
...
...
@@ -58,7 +58,7 @@ var (
// The app that holds all commands and flags.
app
=
flags
.
NewApp
(
gitCommit
,
gitDate
,
"the go-ethereum command line interface"
)
// flags that configure the node
nodeFlags
=
utils
.
GroupFlags
([]
cli
.
Flag
{
nodeFlags
=
flags
.
Merge
([]
cli
.
Flag
{
utils
.
IdentityFlag
,
utils
.
UnlockedAccountFlag
,
utils
.
PasswordFileFlag
,
...
...
@@ -243,7 +243,7 @@ func init() {
}
sort
.
Sort
(
cli
.
CommandsByName
(
app
.
Commands
))
app
.
Flags
=
utils
.
GroupFlags
(
app
.
Flags
=
flags
.
Merge
(
nodeFlags
,
rpcFlags
,
consoleFlags
,
...
...
cmd/geth/snapshot.go
View file @
1ed8b7d2
...
...
@@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
...
...
@@ -56,7 +57,7 @@ var (
Usage
:
"Prune stale ethereum state data based on the snapshot"
,
ArgsUsage
:
"<root>"
,
Action
:
pruneState
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
CacheTrieJournalFlag
,
utils
.
BloomFilterSizeFlag
,
},
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
...
...
@@ -80,7 +81,7 @@ the trie clean cache with default directory will be deleted.
Usage
:
"Recalculate state hash based on the snapshot for verification"
,
ArgsUsage
:
"<root>"
,
Action
:
verifyState
,
Flags
:
utils
.
GroupFlags
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Flags
:
flags
.
Merge
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`
geth snapshot verify-state <state-root>
will traverse the whole accounts and storages set based on the specified
...
...
@@ -93,7 +94,7 @@ In other words, this command does the snapshot to trie conversion.
Usage
:
"Check that there is no 'dangling' snap storage"
,
ArgsUsage
:
"<root>"
,
Action
:
checkDanglingStorage
,
Flags
:
utils
.
GroupFlags
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Flags
:
flags
.
Merge
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`
geth snapshot check-dangling-storage <state-root> traverses the snap storage
data, and verifies that all snapshot storage data has a corresponding account.
...
...
@@ -104,7 +105,7 @@ data, and verifies that all snapshot storage data has a corresponding account.
Usage
:
"Check all snapshot layers for the a specific account"
,
ArgsUsage
:
"<address | hash>"
,
Action
:
checkAccount
,
Flags
:
utils
.
GroupFlags
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Flags
:
flags
.
Merge
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`
geth snapshot inspect-account <address | hash> checks all snapshot layers and prints out
information about the specified address.
...
...
@@ -115,7 +116,7 @@ information about the specified address.
Usage
:
"Traverse the state with given root hash and perform quick verification"
,
ArgsUsage
:
"<root>"
,
Action
:
traverseState
,
Flags
:
utils
.
GroupFlags
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Flags
:
flags
.
Merge
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`
geth snapshot traverse-state <state-root>
will traverse the whole state from the given state root and will abort if any
...
...
@@ -130,7 +131,7 @@ It's also usable without snapshot enabled.
Usage
:
"Traverse the state with given root hash and perform detailed verification"
,
ArgsUsage
:
"<root>"
,
Action
:
traverseRawState
,
Flags
:
utils
.
GroupFlags
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Flags
:
flags
.
Merge
(
utils
.
NetworkFlags
,
utils
.
DatabasePathFlags
),
Description
:
`
geth snapshot traverse-rawstate <state-root>
will traverse the whole state from the given root and will abort if any referenced
...
...
@@ -146,7 +147,7 @@ It's also usable without snapshot enabled.
Usage
:
"Dump a specific block from storage (same as 'geth dump' but using snapshots)"
,
ArgsUsage
:
"[? <blockHash> | <blockNum>]"
,
Action
:
dumpState
,
Flags
:
utils
.
GroupFlags
([]
cli
.
Flag
{
Flags
:
flags
.
Merge
([]
cli
.
Flag
{
utils
.
ExcludeCodeFlag
,
utils
.
ExcludeStorageFlag
,
utils
.
StartKeyFlag
,
...
...
cmd/utils/flags.go
View file @
1ed8b7d2
...
...
@@ -994,15 +994,6 @@ var (
}
)
// GroupFlags combines the given flag slices together and returns the merged one.
func
GroupFlags
(
groups
...
[]
cli
.
Flag
)
[]
cli
.
Flag
{
var
ret
[]
cli
.
Flag
for
_
,
group
:=
range
groups
{
ret
=
append
(
ret
,
group
...
)
}
return
ret
}
// MakeDataDir retrieves the currently requested data directory, terminating
// if none (or the empty string) is specified. If the node is starting a testnet,
// then a subdirectory of the specified datadir will be used.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment