From cd3f0e37b461ee1e253e97f4a171f5f5323976e0 Mon Sep 17 00:00:00 2001 From: MestryOmkar Date: Wed, 24 Oct 2018 14:29:03 +0530 Subject: [PATCH] move gap into genesis config --- cmd/puppeth/wizard_genesis.go | 4 ++++ core/blockchain.go | 6 +++--- miner/worker.go | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 5ca3ca428f..b6da77d5f0 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -108,6 +108,10 @@ func (w *wizard) makeGenesis() { genesis.Config.Clique.Epoch = uint64(w.readDefaultInt(990)) genesis.Config.Clique.RewardCheckpoint = genesis.Config.Clique.Epoch + fmt.Println() + fmt.Println("How many blocks before checkpoint need to prepare new set of masternodes? (default = 50)") + genesis.Config.Clique.Gap = uint64(w.readDefaultInt(50)) + default: log.Crit("Invalid consensus engine choice", "choice", choice) } diff --git a/core/blockchain.go b/core/blockchain.go index 7ad022f4f6..bd3b4d2b51 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -62,7 +62,7 @@ const ( // BlockChainVersion ensures that an incompatible database forces a resync from scratch. BlockChainVersion = 3 - M1Gap = 5 + ) // CacheConfig contains the configuration values for the trie caching/pruning @@ -1193,8 +1193,8 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty CheckpointCh <- 1 } // prepare set of masternodes for the next epoch - if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == (bc.chainConfig.Clique.Epoch - M1Gap) { - M1Ch <- 1 + if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == (bc.chainConfig.Clique.Epoch - bc.chainConfig.Clique.Gap) { + M1Ch <- 1 } } } diff --git a/miner/worker.go b/miner/worker.go index b6473913dc..716379501e 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -588,7 +588,7 @@ func (self *worker) commitNewWork() { core.CheckpointCh <- 1 } // prepare set of masternodes for the next epoch - if (work.Block.NumberU64() % work.config.Clique.Epoch) == (work.config.Clique.Epoch - core.M1Gap) { + if (work.Block.NumberU64() % work.config.Clique.Epoch) == (work.config.Clique.Epoch - work.config.Clique.Gap) { core.M1Ch <- 1 } }