Skip to content

Commit

Permalink
1 Second Blocks (FinTechToken#5)
Browse files Browse the repository at this point in the history
* Lower Minimum Difficulty

* One Second Blocks
  • Loading branch information
TuitionCoin authored and unknown committed May 8, 2018
1 parent 80b405c commit def7154
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Heade
// Some weird constants to avoid constant memory allocs for them.
var (
expDiffPeriod = big.NewInt(100000)
big0 = big.NewInt(0)
big1 = big.NewInt(1)
big2 = big.NewInt(2)
big9 = big.NewInt(9)
Expand Down Expand Up @@ -336,12 +337,15 @@ func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int {

// (2 if len(parent_uncles) else 1) - (block_timestamp - parent_timestamp) // 9
x.Sub(bigTime, bigParentTime)
x.Div(x, big1)
x.Div(x, big2)
if parent.UncleHash == types.EmptyUncleHash {
x.Sub(big1, x)
} else {
x.Sub(big2, x)
}
if x.Cmp(big0) == 0 {
x.Sub(x,big1);
}
// max((2 if len(parent_uncles) else 1) - (block_timestamp - parent_timestamp) // 9, -99)
if x.Cmp(bigMinus99) < 0 {
x.Set(bigMinus99)
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (self *worker) commitNewWork() {
}
// this will ensure we're not going off too far in the future
if now := time.Now().Unix(); tstamp > now+1 {
wait := time.Duration(tstamp-now) * time.Second
wait := time.Duration(tstamp-now-1) * time.Second
log.Info("Mining too far in the future", "wait", common.PrettyDuration(wait))
time.Sleep(wait)
}
Expand Down

0 comments on commit def7154

Please sign in to comment.