-
Notifications
You must be signed in to change notification settings - Fork 182
/
minter_okchain.go
44 lines (37 loc) · 1.42 KB
/
minter_okchain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package types
import (
"fmt"
"github.com/okex/exchain/libs/cosmos-sdk/types"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
)
type MinterCustom struct {
NextBlockToUpdate uint64 `json:"next_block_to_update" yaml:"next_block_to_update"` // record the block height for next year
MintedPerBlock types.DecCoins `json:"minted_per_block" yaml:"minted_per_block"` // record the MintedPerBlock per block in this year
}
// NewMinterCustom returns a new Minter object with the given inflation and annual
// provisions values.
func NewMinterCustom(nextBlockToUpdate uint64, mintedPerBlock sdk.DecCoins) MinterCustom {
return MinterCustom{
NextBlockToUpdate: nextBlockToUpdate,
MintedPerBlock: mintedPerBlock,
}
}
// InitialMinterCustom returns an initial Minter object with a given inflation value.
func InitialMinterCustom() MinterCustom {
return NewMinterCustom(
0,
sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.ZeroInt())},
)
}
// DefaultInitialMinterCustom returns a default initial MinterCustom object for a new chain
// which uses an inflation rate of 1%.
func DefaultInitialMinterCustom() MinterCustom {
return InitialMinterCustom()
}
// ValidateMinterCustom validate minter
func ValidateMinterCustom(minter MinterCustom) error {
if len(minter.MintedPerBlock) != 1 || minter.MintedPerBlock[0].Denom != sdk.DefaultBondDenom {
return fmt.Errorf(" MintedPerBlock must contain only %s", sdk.DefaultBondDenom)
}
return nil
}