Merge PR #3621: module inter-dependency cleanup
This commit is contained in:
committed by
Jack Zampolin
parent
dafe0acf4f
commit
d66db6a772
@@ -0,0 +1,10 @@
|
||||
package types
|
||||
|
||||
// An Invariant is a function which tests a particular invariant.
|
||||
// If the invariant has been broken, it should return an error
|
||||
// containing a descriptive message about what happened.
|
||||
// The simulator will then halt and print the logs.
|
||||
type Invariant func(ctx Context) error
|
||||
|
||||
// group of Invarient
|
||||
type Invariants []Invariant
|
||||
+26
-1
@@ -1,6 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
)
|
||||
@@ -8,11 +10,21 @@ import (
|
||||
// status of a validator
|
||||
type BondStatus byte
|
||||
|
||||
// nolint
|
||||
// staking constants
|
||||
const (
|
||||
Unbonded BondStatus = 0x00
|
||||
Unbonding BondStatus = 0x01
|
||||
Bonded BondStatus = 0x02
|
||||
|
||||
// default bond denomination
|
||||
DefaultBondDenom = "stake"
|
||||
|
||||
// Delay, in blocks, between when validator updates are returned to Tendermint and when they are applied.
|
||||
// For example, if this is 0, the validator set at the end of a block will sign the next block, or
|
||||
// if this is 1, the validator set at the end of a block will sign the block after the next.
|
||||
// Constant as this should not change without a hard fork.
|
||||
// TODO: Link to some Tendermint docs, this is very unobvious.
|
||||
ValidatorUpdateDelay int64 = 1
|
||||
)
|
||||
|
||||
//BondStatusToString for pretty prints of Bond Status
|
||||
@@ -29,6 +41,19 @@ func BondStatusToString(b BondStatus) string {
|
||||
}
|
||||
}
|
||||
|
||||
// PowerReduction is the amount of staking tokens required for 1 unit of Tendermint power
|
||||
var PowerReduction = NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(6), nil))
|
||||
|
||||
// TokensToTendermintPower - convert input tokens to potential tendermint power
|
||||
func TokensToTendermintPower(tokens Int) int64 {
|
||||
return (tokens.Div(PowerReduction)).Int64()
|
||||
}
|
||||
|
||||
// TokensFromTendermintPower - convert input power to tokens
|
||||
func TokensFromTendermintPower(power int64) Int {
|
||||
return NewInt(power).Mul(PowerReduction)
|
||||
}
|
||||
|
||||
// nolint
|
||||
func (b BondStatus) Equal(b2 BondStatus) bool {
|
||||
return byte(b) == byte(b2)
|
||||
|
||||
Reference in New Issue
Block a user