core/block_validator: remove unused diff timespan vars/functions (relocated to ubqhash/consensus)

This commit is contained in:
Luke Williams 2019-05-14 21:32:25 +02:00
parent 204aa74b6d
commit 78fb24543b

View file

@ -25,109 +25,6 @@ import (
"github.com/ubiq/go-ubiq/params" "github.com/ubiq/go-ubiq/params"
) )
var (
big88 = big.NewInt(88)
bigMinus99 = big.NewInt(-99)
nPowAveragingWindow = big.NewInt(21)
nPowMaxAdjustDown = big.NewInt(16) // 16% adjustment down
nPowMaxAdjustUp = big.NewInt(8) // 8% adjustment up
diffChangeBlock = big.NewInt(4088)
nPowAveragingWindow88 = big.NewInt(88)
nPowMaxAdjustDown2 = big.NewInt(3) // 3% adjustment down
nPowMaxAdjustUp2 = big.NewInt(2) // 2% adjustment up
// Flux
fluxChangeBlock = big.NewInt(8000)
nPowMaxAdjustDownFlux = big.NewInt(5) // 0.5% adjustment down
nPowMaxAdjustUpFlux = big.NewInt(3) // 0.3% adjustment up
nPowDampFlux = big.NewInt(1) // 0.1%
)
func AveragingWindowTimespan() *big.Int {
x := new(big.Int)
return x.Mul(nPowAveragingWindow, big88)
}
func MinActualTimespan() *big.Int {
// (AveragingWindowTimespan() * (100 - nPowMaxAdjustUp )) / 100
x := new(big.Int)
y := new(big.Int)
z := new(big.Int)
x.Sub(big.NewInt(100), nPowMaxAdjustUp)
y.Mul(AveragingWindowTimespan(), x)
z.Div(y, big.NewInt(100))
return z
}
func MaxActualTimespan() *big.Int {
// (AveragingWindowTimespan() * (100 + nPowMaxAdjustDown)) / 100
x := new(big.Int)
y := new(big.Int)
z := new(big.Int)
x.Add(big.NewInt(100), nPowMaxAdjustDown)
y.Mul(AveragingWindowTimespan(), x)
z.Div(y, big.NewInt(100))
return z
}
func AveragingWindowTimespan88() *big.Int {
x := new(big.Int)
return x.Mul(nPowAveragingWindow88, big88)
}
func MinActualTimespan2() *big.Int {
x := new(big.Int)
y := new(big.Int)
z := new(big.Int)
x.Sub(big.NewInt(100), nPowMaxAdjustUp2)
y.Mul(AveragingWindowTimespan88(), x)
z.Div(y, big.NewInt(100))
return z
}
func MaxActualTimespan2() *big.Int {
x := new(big.Int)
y := new(big.Int)
z := new(big.Int)
x.Add(big.NewInt(100), nPowMaxAdjustDown2)
y.Mul(AveragingWindowTimespan88(), x)
z.Div(y, big.NewInt(100))
return z
}
func MinActualTimespanFlux(dampen bool) *big.Int {
x := new(big.Int)
y := new(big.Int)
z := new(big.Int)
if dampen {
x.Sub(big.NewInt(1000), nPowDampFlux)
y.Mul(AveragingWindowTimespan88(), x)
z.Div(y, big.NewInt(1000))
} else {
x.Sub(big.NewInt(1000), nPowMaxAdjustUpFlux)
y.Mul(AveragingWindowTimespan88(), x)
z.Div(y, big.NewInt(1000))
}
return z
}
func MaxActualTimespanFlux(dampen bool) *big.Int {
x := new(big.Int)
y := new(big.Int)
z := new(big.Int)
if dampen {
x.Add(big.NewInt(1000), nPowDampFlux)
y.Mul(AveragingWindowTimespan88(), x)
z.Div(y, big.NewInt(1000))
} else {
x.Add(big.NewInt(1000), nPowMaxAdjustDownFlux)
y.Mul(AveragingWindowTimespan88(), x)
z.Div(y, big.NewInt(1000))
}
return z
}
// BlockValidator is responsible for validating block headers, uncles and // BlockValidator is responsible for validating block headers, uncles and
// processed state. // processed state.
// //