mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
add shh command line option to switch on/off whisper
This commit is contained in:
parent
9380644db0
commit
ba0ede1201
4 changed files with 18 additions and 8 deletions
|
|
@ -59,6 +59,7 @@ var (
|
||||||
DumpNumber int
|
DumpNumber int
|
||||||
VmType int
|
VmType int
|
||||||
ImportChain string
|
ImportChain string
|
||||||
|
SHH bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// flags specific to cli client
|
// flags specific to cli client
|
||||||
|
|
@ -94,6 +95,7 @@ func Init() {
|
||||||
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
|
flag.BoolVar(&StartWebSockets, "ws", false, "start websocket server")
|
||||||
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
|
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
|
||||||
flag.BoolVar(&UseSeed, "seed", true, "seed peers")
|
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.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
|
||||||
flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)")
|
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")
|
flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given")
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ func main() {
|
||||||
|
|
||||||
clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier, string(keyManager.PublicKey()))
|
clientIdentity := utils.NewClientIdentity(ClientIdentifier, Version, Identifier, string(keyManager.PublicKey()))
|
||||||
|
|
||||||
ethereum := utils.NewEthereum(db, clientIdentity, keyManager, utils.NatType(NatType, PMPGateway), OutboundPort, MaxPeer)
|
ethereum := utils.NewEthereum(db, clientIdentity, keyManager, utils.NatType(NatType, PMPGateway), OutboundPort, MaxPeer, SHH)
|
||||||
|
|
||||||
if Dump {
|
if Dump {
|
||||||
var block *types.Block
|
var block *types.Block
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,8 @@ func NatType(natType string, gateway string) (nat p2p.NAT) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEthereum(db ethutil.Database, clientIdentity p2p.ClientIdentity, keyManager *crypto.KeyManager, nat p2p.NAT, OutboundPort string, MaxPeer int) *eth.Ethereum {
|
func NewEthereum(db ethutil.Database, clientIdentity p2p.ClientIdentity, keyManager *crypto.KeyManager, nat p2p.NAT, OutboundPort string, MaxPeer int, SHH bool) *eth.Ethereum {
|
||||||
ethereum, err := eth.New(db, clientIdentity, keyManager, nat, OutboundPort, MaxPeer)
|
ethereum, err := eth.New(db, clientIdentity, keyManager, nat, OutboundPort, MaxPeer, SHH)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
clilogger.Fatalln("eth start err:", err)
|
clilogger.Fatalln("eth start err:", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ type Ethereum struct {
|
||||||
Mining bool
|
Mining bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.KeyManager, nat p2p.NAT, port string, maxPeers int) (*Ethereum, error) {
|
func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.KeyManager, nat p2p.NAT, port string, maxPeers int, shh bool) (*Ethereum, error) {
|
||||||
|
|
||||||
saveProtocolVersion(db)
|
saveProtocolVersion(db)
|
||||||
ethutil.Config.Db = db
|
ethutil.Config.Db = db
|
||||||
|
|
@ -73,7 +73,6 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
|
||||||
eth.txPool = core.NewTxPool(eth.chainManager, eth.EventMux())
|
eth.txPool = core.NewTxPool(eth.chainManager, eth.EventMux())
|
||||||
eth.blockManager = core.NewBlockManager(eth.txPool, eth.chainManager, eth.EventMux())
|
eth.blockManager = core.NewBlockManager(eth.txPool, eth.chainManager, eth.EventMux())
|
||||||
eth.chainManager.SetProcessor(eth.blockManager)
|
eth.chainManager.SetProcessor(eth.blockManager)
|
||||||
eth.whisper = whisper.New()
|
|
||||||
|
|
||||||
hasBlock := eth.chainManager.HasBlock
|
hasBlock := eth.chainManager.HasBlock
|
||||||
insertChain := eth.chainManager.InsertChain
|
insertChain := eth.chainManager.InsertChain
|
||||||
|
|
@ -83,7 +82,12 @@ func New(db ethutil.Database, identity p2p.ClientIdentity, keyManager *crypto.Ke
|
||||||
eth.txPool.Start()
|
eth.txPool.Start()
|
||||||
|
|
||||||
ethProto := EthProtocol(eth.txPool, eth.chainManager, eth.blockPool)
|
ethProto := EthProtocol(eth.txPool, eth.chainManager, eth.blockPool)
|
||||||
protocols := []p2p.Protocol{ethProto, eth.whisper.Protocol()}
|
protocols := []p2p.Protocol{ethProto}
|
||||||
|
|
||||||
|
if shh {
|
||||||
|
eth.whisper = whisper.New()
|
||||||
|
protocols = append(protocols, eth.whisper.Protocol())
|
||||||
|
}
|
||||||
|
|
||||||
server := &p2p.Server{
|
server := &p2p.Server{
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
|
|
@ -165,7 +169,9 @@ func (s *Ethereum) Start(seed bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.blockPool.Start()
|
s.blockPool.Start()
|
||||||
s.whisper.Start()
|
if s.whisper != nil {
|
||||||
|
s.whisper.Start()
|
||||||
|
}
|
||||||
|
|
||||||
// broadcast transactions
|
// broadcast transactions
|
||||||
s.txSub = s.eventMux.Subscribe(core.TxPreEvent{})
|
s.txSub = s.eventMux.Subscribe(core.TxPreEvent{})
|
||||||
|
|
@ -213,7 +219,9 @@ func (s *Ethereum) Stop() {
|
||||||
s.txPool.Stop()
|
s.txPool.Stop()
|
||||||
s.eventMux.Stop()
|
s.eventMux.Stop()
|
||||||
s.blockPool.Stop()
|
s.blockPool.Stop()
|
||||||
s.whisper.Stop()
|
if s.whisper != nil {
|
||||||
|
s.whisper.Stop()
|
||||||
|
}
|
||||||
|
|
||||||
ethlogger.Infoln("Server stopped")
|
ethlogger.Infoln("Server stopped")
|
||||||
close(s.shutdownChan)
|
close(s.shutdownChan)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue