core/headerchain: add BigIntSlice sort functions

This commit is contained in:
Luke Williams 2019-03-09 07:57:02 +01:00
parent 7319087fb6
commit 112cdc5853

View file

@ -528,3 +528,10 @@ func (hc *HeaderChain) Engine() consensus.Engine { return hc.engine }
func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block { func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block {
return nil 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] }