From 112cdc5853a2c921781c2ade712de76bdb3bb1b0 Mon Sep 17 00:00:00 2001 From: Luke Williams Date: Sat, 9 Mar 2019 07:57:02 +0100 Subject: [PATCH] core/headerchain: add BigIntSlice sort functions --- core/headerchain.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/headerchain.go b/core/headerchain.go index 78ab09cd95..d4522e709b 100644 --- a/core/headerchain.go +++ b/core/headerchain.go @@ -528,3 +528,10 @@ func (hc *HeaderChain) Engine() consensus.Engine { return hc.engine } func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block { return nil } + +// BigIntSlice attaches the methods of sort.Interface to []*big.Int, sorting in increasing order. (used by CalcPastMedianTime) +type BigIntSlice []*big.Int + +func (s BigIntSlice) Len() int { return len(s) } +func (s BigIntSlice) Less(i, j int) bool { return s[i].Cmp(s[j]) < 0 } +func (s BigIntSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }