core/headerchain: CalcPastMedianTime, uint64 timestamps

This commit is contained in:
Luke Williams 2019-05-16 18:00:29 +02:00
parent cdb4f3ef5b
commit 0a4c319866

View file

@ -24,6 +24,7 @@ import (
"math/big" "math/big"
mrand "math/rand" mrand "math/rand"
"sync/atomic" "sync/atomic"
"sort"
"time" "time"
"github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/common"
@ -397,7 +398,7 @@ func (hc *HeaderChain) CalcPastMedianTime(number uint64, parent *types.Header) *
// Genesis block. // Genesis block.
if number == 0 { if number == 0 {
return hc.GetHeaderByNumber(0).Time return big.NewInt(int64(hc.GetHeaderByNumber(0).Time))
} }
timestamps := make([]*big.Int, medianTimeBlocks) timestamps := make([]*big.Int, medianTimeBlocks)
@ -409,10 +410,10 @@ func (hc *HeaderChain) CalcPastMedianTime(number uint64, parent *types.Header) *
for i := number; i >= limit; i-- { for i := number; i >= limit; i-- {
if parent != nil && i == number { if parent != nil && i == number {
timestamps[numNodes] = parent.Time timestamps[numNodes] = big.NewInt(int64(parent.Time))
} else { } else {
header := hc.GetHeaderByNumber(i) header := hc.GetHeaderByNumber(i)
timestamps[numNodes] = header.Time timestamps[numNodes] = big.NewInt(int64(header.Time))
} }
numNodes++ numNodes++
if i == 0 { if i == 0 {