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
7a11e864
Commit
7a11e864
authored
Jun 21, 2017
by
Bas van Kervel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: move flags from whisper package to utils
parent
4a1d516d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
37 deletions
+34
-37
config.go
cmd/geth/config.go
+7
-7
main.go
cmd/geth/main.go
+7
-2
usage.go
cmd/geth/usage.go
+1
-2
flags.go
cmd/utils/flags.go
+18
-4
config.go
whisper/whisperv5/config.go
+1
-22
No files found.
cmd/geth/config.go
View file @
7a11e864
...
@@ -43,7 +43,7 @@ var (
...
@@ -43,7 +43,7 @@ var (
Name
:
"dumpconfig"
,
Name
:
"dumpconfig"
,
Usage
:
"Show configuration values"
,
Usage
:
"Show configuration values"
,
ArgsUsage
:
""
,
ArgsUsage
:
""
,
Flags
:
append
(
append
(
nodeFlags
,
rpcFlags
...
),
whisper
.
Flags
...
),
Flags
:
append
(
append
(
nodeFlags
,
rpcFlags
...
),
whisperFlags
...
),
Category
:
"MISCELLANEOUS COMMANDS"
,
Category
:
"MISCELLANEOUS COMMANDS"
,
Description
:
`The dumpconfig command shows configuration values.`
,
Description
:
`The dumpconfig command shows configuration values.`
,
}
}
...
@@ -140,7 +140,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
...
@@ -140,7 +140,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
// enableWhisper returns true in case one of the whisper flags is set.
// enableWhisper returns true in case one of the whisper flags is set.
func
enableWhisper
(
ctx
*
cli
.
Context
)
bool
{
func
enableWhisper
(
ctx
*
cli
.
Context
)
bool
{
for
_
,
flag
:=
range
whisper
.
Flags
{
for
_
,
flag
:=
range
whisperFlags
{
if
ctx
.
GlobalIsSet
(
flag
.
GetName
())
{
if
ctx
.
GlobalIsSet
(
flag
.
GetName
())
{
return
true
return
true
}
}
...
@@ -155,13 +155,13 @@ func makeFullNode(ctx *cli.Context) *node.Node {
...
@@ -155,13 +155,13 @@ func makeFullNode(ctx *cli.Context) *node.Node {
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
shhEnabled
:=
enableWhisper
(
ctx
)
shhEnabled
:=
enableWhisper
(
ctx
)
shhAutoEnabled
:=
!
ctx
.
GlobalIsSet
(
whisper
.
WhisperEnabledFlag
.
Name
)
&&
ctx
.
GlobalIsSet
(
utils
.
DevModeFlag
.
Name
)
shhAutoEnabled
:=
!
ctx
.
GlobalIsSet
(
utils
.
WhisperEnabledFlag
.
Name
)
&&
ctx
.
GlobalIsSet
(
utils
.
DevModeFlag
.
Name
)
if
shhEnabled
||
shhAutoEnabled
{
if
shhEnabled
||
shhAutoEnabled
{
if
ctx
.
GlobalIsSet
(
whisper
.
MaxMessageSizeFlag
.
Name
)
{
if
ctx
.
GlobalIsSet
(
utils
.
Whisper
MaxMessageSizeFlag
.
Name
)
{
cfg
.
Shh
.
MaxMessageSize
=
uint32
(
ctx
.
Int
(
whisper
.
MaxMessageSizeFlag
.
Name
))
cfg
.
Shh
.
MaxMessageSize
=
uint32
(
ctx
.
Int
(
utils
.
Whisper
MaxMessageSizeFlag
.
Name
))
}
}
if
ctx
.
GlobalIsSet
(
whisper
.
MinPOWFlag
.
Name
)
{
if
ctx
.
GlobalIsSet
(
utils
.
Whisper
MinPOWFlag
.
Name
)
{
cfg
.
Shh
.
MinimumAcceptedPOW
=
ctx
.
Float64
(
whisper
.
MinPOWFlag
.
Name
)
cfg
.
Shh
.
MinimumAcceptedPOW
=
ctx
.
Float64
(
utils
.
Whisper
MinPOWFlag
.
Name
)
}
}
utils
.
RegisterShhService
(
stack
,
&
cfg
.
Shh
)
utils
.
RegisterShhService
(
stack
,
&
cfg
.
Shh
)
}
}
...
...
cmd/geth/main.go
View file @
7a11e864
...
@@ -35,7 +35,6 @@ import (
...
@@ -35,7 +35,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/node"
whisper
"github.com/ethereum/go-ethereum/whisper/whisperv5"
"gopkg.in/urfave/cli.v1"
"gopkg.in/urfave/cli.v1"
)
)
...
@@ -125,6 +124,12 @@ var (
...
@@ -125,6 +124,12 @@ var (
utils
.
IPCDisabledFlag
,
utils
.
IPCDisabledFlag
,
utils
.
IPCPathFlag
,
utils
.
IPCPathFlag
,
}
}
whisperFlags
=
[]
cli
.
Flag
{
utils
.
WhisperEnabledFlag
,
utils
.
WhisperMaxMessageSizeFlag
,
utils
.
WhisperMinPOWFlag
,
}
)
)
func
init
()
{
func
init
()
{
...
@@ -161,7 +166,7 @@ func init() {
...
@@ -161,7 +166,7 @@ func init() {
app
.
Flags
=
append
(
app
.
Flags
,
rpcFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
rpcFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
consoleFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
consoleFlags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
debug
.
Flags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
debug
.
Flags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
whisper
.
Flags
...
)
app
.
Flags
=
append
(
app
.
Flags
,
whisperFlags
...
)
app
.
Before
=
func
(
ctx
*
cli
.
Context
)
error
{
app
.
Before
=
func
(
ctx
*
cli
.
Context
)
error
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
...
...
cmd/geth/usage.go
View file @
7a11e864
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/whisper/whisperv5"
"gopkg.in/urfave/cli.v1"
"gopkg.in/urfave/cli.v1"
)
)
...
@@ -190,7 +189,7 @@ var AppHelpFlagGroups = []flagGroup{
...
@@ -190,7 +189,7 @@ var AppHelpFlagGroups = []flagGroup{
},
},
{
{
Name
:
"Whisper (EXPERIMENTAL)"
,
Name
:
"Whisper (EXPERIMENTAL)"
,
Flags
:
whisper
v5
.
Flags
,
Flags
:
whisperFlags
,
},
},
{
{
Name
:
"DEPRECATED"
,
Name
:
"DEPRECATED"
,
...
...
cmd/utils/flags.go
View file @
7a11e864
...
@@ -458,6 +458,20 @@ var (
...
@@ -458,6 +458,20 @@ var (
Usage
:
"Suggested gas price is the given percentile of a set of recent transaction gas prices"
,
Usage
:
"Suggested gas price is the given percentile of a set of recent transaction gas prices"
,
Value
:
eth
.
DefaultConfig
.
GPO
.
Percentile
,
Value
:
eth
.
DefaultConfig
.
GPO
.
Percentile
,
}
}
WhisperEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"shh"
,
Usage
:
"Enable Whisper"
,
}
WhisperMaxMessageSizeFlag
=
cli
.
IntFlag
{
Name
:
"shh.maxmessagesize"
,
Usage
:
"Max message size accepted"
,
Value
:
int
(
whisper
.
DefaultMaxMessageSize
),
}
WhisperMinPOWFlag
=
cli
.
Float64Flag
{
Name
:
"shh.pow"
,
Usage
:
"Minimum POW accepted"
,
Value
:
whisper
.
DefaultMinimumPoW
,
}
)
)
// MakeDataDir retrieves the currently requested data directory, terminating
// MakeDataDir retrieves the currently requested data directory, terminating
...
@@ -875,11 +889,11 @@ func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
...
@@ -875,11 +889,11 @@ func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
// SetShhConfig applies shh-related command line flags to the config.
// SetShhConfig applies shh-related command line flags to the config.
func
SetShhConfig
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
,
cfg
*
whisper
.
Config
)
{
func
SetShhConfig
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
,
cfg
*
whisper
.
Config
)
{
if
ctx
.
GlobalIsSet
(
whisper
.
MaxMessageSizeFlag
.
Name
)
{
if
ctx
.
GlobalIsSet
(
Whisper
MaxMessageSizeFlag
.
Name
)
{
cfg
.
MaxMessageSize
=
uint32
(
ctx
.
GlobalUint
(
whisper
.
MaxMessageSizeFlag
.
Name
))
cfg
.
MaxMessageSize
=
uint32
(
ctx
.
GlobalUint
(
Whisper
MaxMessageSizeFlag
.
Name
))
}
}
if
ctx
.
GlobalIsSet
(
whisper
.
MinPOWFlag
.
Name
)
{
if
ctx
.
GlobalIsSet
(
Whisper
MinPOWFlag
.
Name
)
{
cfg
.
MinimumAcceptedPOW
=
ctx
.
GlobalFloat64
(
whisper
.
MinPOWFlag
.
Name
)
cfg
.
MinimumAcceptedPOW
=
ctx
.
GlobalFloat64
(
Whisper
MinPOWFlag
.
Name
)
}
}
}
}
...
...
whisper/whisperv5/config.go
View file @
7a11e864
...
@@ -16,10 +16,6 @@
...
@@ -16,10 +16,6 @@
package
whisperv5
package
whisperv5
import
(
"gopkg.in/urfave/cli.v1"
)
type
Config
struct
{
type
Config
struct
{
MaxMessageSize
uint32
`toml:",omitempty"`
MaxMessageSize
uint32
`toml:",omitempty"`
MinimumAcceptedPOW
float64
`toml:",omitempty"`
MinimumAcceptedPOW
float64
`toml:",omitempty"`
...
@@ -30,21 +26,4 @@ var DefaultConfig = Config{
...
@@ -30,21 +26,4 @@ var DefaultConfig = Config{
MinimumAcceptedPOW
:
DefaultMinimumPoW
,
MinimumAcceptedPOW
:
DefaultMinimumPoW
,
}
}
var
(
var
()
WhisperEnabledFlag
=
cli
.
BoolFlag
{
Name
:
"shh"
,
Usage
:
"Enable Whisper"
,
}
MaxMessageSizeFlag
=
cli
.
IntFlag
{
Name
:
"shh.maxmessagesize"
,
Usage
:
"Max message size accepted"
,
Value
:
int
(
DefaultMaxMessageSize
),
}
MinPOWFlag
=
cli
.
Float64Flag
{
Name
:
"shh.pow"
,
Usage
:
"Minimum POW accepted"
,
Value
:
DefaultMinimumPoW
,
}
Flags
=
[]
cli
.
Flag
{
WhisperEnabledFlag
,
MaxMessageSizeFlag
,
MinPOWFlag
}
)
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