Update consensus.go

This commit is contained in:
etherinc 2018-02-13 00:18:10 +05:30 committed by GitHub
parent e5bd0394cd
commit 4566a31ba1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"math/big" "math/big"
"math"
"runtime" "runtime"
"time" "time"
@ -535,12 +536,12 @@ var (
) )
// calculate reward for miners // calculate reward for miners
func calculateReward(reward int, currentTimestamp int64) (blockReward *big.Int) { func calculateReward(reward int, currentTimestamp uint64) (blockReward *big.Int) {
rewardMaxDecimal := 7 rewardMaxDecimal := 7
currentReward := float64(reward) * math.Pow(10, float64(rewardMaxDecimal)) currentReward := float64(reward) * math.Pow(10, float64(rewardMaxDecimal))
rewardDecreaseTime := int64(3*365*24*60*60) rewardDecreaseTime := int64(3*365*24*60*60)
fromTimestamp := int64(1518395555) fromTimestamp := int64(1518395555)
timeDiff := currentTimestamp - fromTimestamp timeDiff := int64(currentTimestamp) - fromTimestamp
if timeDiff >= rewardDecreaseTime { if timeDiff >= rewardDecreaseTime {
newDiff := int(timeDiff / rewardDecreaseTime) newDiff := int(timeDiff / rewardDecreaseTime)