From f641fce66bf80a62bf5356631aa6d2926436712d Mon Sep 17 00:00:00 2001 From: Sunny Katkuri Date: Thu, 20 Sep 2018 17:30:47 +0000 Subject: [PATCH] Add command line flag to enable graphene --- cmd/geth/main.go | 1 + cmd/geth/usage.go | 1 + cmd/utils/flags.go | 8 ++++++++ eth/backend.go | 2 +- eth/handler.go | 4 ++-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index fae4b57181..4c42c25ab6 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -132,6 +132,7 @@ var ( utils.GpoPercentileFlag, utils.EWASMInterpreterFlag, utils.EVMInterpreterFlag, + utils.UseGrapheneFlag, configFileFlag, } diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 8b0491ce3c..3df453eb92 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -81,6 +81,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.LightServFlag, utils.LightPeersFlag, utils.LightKDFFlag, + utils.UseGrapheneFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a2becd08b8..43632d044e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -621,6 +621,10 @@ var ( Usage: "External EVM configuration (default = built-in interpreter)", Value: "", } + UseGrapheneFlag = cli.BoolFlag{ + Name: "graphene", + Usage: "Enable graphene protocol for block propagation", + } ) // MakeDataDir retrieves the currently requested data directory, terminating @@ -1246,6 +1250,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 { state.MaxTrieCacheGen = uint16(gen) } + + if ctx.GlobalIsSet(UseGrapheneFlag.Name) { + cfg.UseGraphene = ctx.GlobalBool(NoGossipFlag.Name) + } } // SetDashboardConfig applies dashboard related command line flags to the config. diff --git a/eth/backend.go b/eth/backend.go index 90d185ed48..fd1ad559be 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -173,7 +173,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } eth.txPool = core.NewTxPool(config.TxPool, eth.chainConfig, eth.blockchain) - if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb); err != nil { + if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb, config.UseGraphene); err != nil { return nil, err } diff --git a/eth/handler.go b/eth/handler.go index dfe0b30db4..9f82f9de84 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -123,7 +123,7 @@ type ProtocolManager struct { // NewProtocolManager returns a new Ethereum sub protocol manager. The Ethereum sub protocol manages peers capable // with the Ethereum network. -func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkID uint64, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) { +func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkID uint64, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb ethdb.Database, bool useGraphene) (*ProtocolManager, error) { // Create the protocol manager with the base fields manager := &ProtocolManager{ networkID: networkID, @@ -136,7 +136,7 @@ func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, ne noMorePeers: make(chan struct{}), txsyncCh: make(chan *txsync), quitSync: make(chan struct{}), - useGraphene: false, + useGraphene: useGraphene, } // Figure out whether to allow fast sync or not if mode == downloader.FastSync && blockchain.CurrentBlock().NumberU64() > 0 {