mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/headerchain: CalcPastMedianTime, uint64 timestamps
This commit is contained in:
parent
cdb4f3ef5b
commit
0a4c319866
1 changed files with 4 additions and 3 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue