Skip to content

Commit

Permalink
Merge pull request ethereum#108 from ngtuna/m1gap
Browse files Browse the repository at this point in the history
move gap into genesis config
  • Loading branch information
ngtuna authored Jul 31, 2018
2 parents 4e9666b + 3442205 commit b1c8d65
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ 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
Expand Down Expand Up @@ -1193,7 +1192,7 @@ 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) {
if (chain[i].NumberU64() % bc.chainConfig.Clique.Epoch) == (bc.chainConfig.Clique.Epoch - bc.chainConfig.Clique.Gap) {
M1Ch <- 1
}
}
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
1 change: 1 addition & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ type CliqueConfig struct {
Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint
Reward uint64 `json:"reward"` // Block reward - unit Ether
RewardCheckpoint uint64 `json:"rewardCheckpoint"` // Checkpoint block for calculate rewards.
Gap uint64 `json:"gap"` // Gap time preparing for the next epoch
}

// String implements the stringer interface, returning the consensus engine details.
Expand Down

0 comments on commit b1c8d65

Please sign in to comment.