mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
add shh command line option to switch on/off whisper
This commit is contained in:
parent
c2184512bb
commit
b44289ec12
3 changed files with 23 additions and 7 deletions
|
|
@ -59,6 +59,7 @@ var (
|
|||
DumpNumber int
|
||||
VmType int
|
||||
ImportChain string
|
||||
SHH bool
|
||||
)
|
||||
|
||||
// flags specific to cli client
|
||||
|
|
@ -94,6 +95,7 @@ func Init() {
|
|||
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
|
||||
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
|
||||
flag.BoolVar(&UseSeed, "seed", true, "seed peers")
|
||||
flag.BoolVar(&SHH, "shh", true, "whisper protocol (on)")
|
||||
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
|
||||
flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
|
||||
flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")
|
||||
|
|
|
|||
|
|
@ -64,10 +64,13 @@ func main() {
|
|||
NATType: PMPGateway,
|
||||
PMPGateway: PMPGateway,
|
||||
KeyRing: KeyRing,
|
||||
Shh: SHH,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
clilogger.Fatalln(err)
|
||||
}
|
||||
|
||||
utils.KeyTasks(ethereum.KeyManager(), KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive)
|
||||
|
||||
if Dump {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ type Config struct {
|
|||
NATType string
|
||||
PMPGateway string
|
||||
|
||||
Shh bool
|
||||
|
||||
KeyManager *crypto.KeyManager
|
||||
}
|
||||
|
||||
|
|
@ -124,17 +126,18 @@ func New(config *Config) (*Ethereum, error) {
|
|||
eth.txPool = core.NewTxPool(eth.EventMux())
|
||||
eth.blockManager = core.NewBlockManager(eth.txPool, eth.chainManager, eth.EventMux())
|
||||
eth.chainManager.SetProcessor(eth.blockManager)
|
||||
eth.whisper = whisper.New()
|
||||
|
||||
hasBlock := eth.chainManager.HasBlock
|
||||
insertChain := eth.chainManager.InsertChain
|
||||
eth.blockPool = NewBlockPool(hasBlock, insertChain, ezp.Verify)
|
||||
|
||||
// Start services
|
||||
eth.txPool.Start()
|
||||
|
||||
ethProto := EthProtocol(eth.txPool, eth.chainManager, eth.blockPool)
|
||||
protocols := []p2p.Protocol{ethProto, eth.whisper.Protocol()}
|
||||
protocols := []p2p.Protocol{ethProto}
|
||||
|
||||
if config.Shh {
|
||||
eth.whisper = whisper.New()
|
||||
protocols = append(protocols, eth.whisper.Protocol())
|
||||
}
|
||||
|
||||
nat, err := p2p.ParseNAT(config.NATType, config.PMPGateway)
|
||||
if err != nil {
|
||||
|
|
@ -222,8 +225,14 @@ func (s *Ethereum) Start(seed bool) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start services
|
||||
s.txPool.Start()
|
||||
s.blockPool.Start()
|
||||
s.whisper.Start()
|
||||
|
||||
if s.whisper != nil {
|
||||
s.whisper.Start()
|
||||
}
|
||||
|
||||
// broadcast transactions
|
||||
s.txSub = s.eventMux.Subscribe(core.TxPreEvent{})
|
||||
|
|
@ -271,7 +280,9 @@ func (s *Ethereum) Stop() {
|
|||
s.txPool.Stop()
|
||||
s.eventMux.Stop()
|
||||
s.blockPool.Stop()
|
||||
s.whisper.Stop()
|
||||
if s.whisper != nil {
|
||||
s.whisper.Stop()
|
||||
}
|
||||
|
||||
ethlogger.Infoln("Server stopped")
|
||||
close(s.shutdownChan)
|
||||
|
|
|
|||
Loading…
Reference in a new issue