github.com/Finschia/finschia-sdk@v0.48.1/types/staking.go (about)

     1  package types
     2  
     3  // staking constants
     4  const (
     5  
     6  	// default bond denomination
     7  	DefaultBondDenom = "stake"
     8  
     9  	// Delay, in blocks, between when validator updates are returned to the
    10  	// consensus-engine and when they are applied. For example, if
    11  	// ValidatorUpdateDelay is set to X, and if a validator set update is
    12  	// returned with new validators at the end of block 10, then the new
    13  	// validators are expected to sign blocks beginning at block 11+X.
    14  	//
    15  	// This value is constant as this should not change without a hard fork.
    16  	// For Tendermint this should be set to 1 block, for more details see:
    17  	// https://tendermint.com/docs/spec/abci/apps.html#endblock
    18  	ValidatorUpdateDelay int64 = 1
    19  )
    20  
    21  // DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
    22  var DefaultPowerReduction = NewIntFromUint64(1000000)
    23  
    24  // TokensToConsensusPower - convert input tokens to potential consensus-engine power
    25  func TokensToConsensusPower(tokens Int, powerReduction Int) int64 {
    26  	return (tokens.Quo(powerReduction)).Int64()
    27  }
    28  
    29  // TokensFromConsensusPower - convert input power to tokens
    30  func TokensFromConsensusPower(power int64, powerReduction Int) Int {
    31  	return NewInt(power).Mul(powerReduction)
    32  }