Skip to content

Commit

Permalink
refactor: removing json and cbor tags from chain params
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Aug 10, 2024
1 parent 3bb1f5e commit 83fe68b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Genesis struct {

type genesisData struct {
GenesisTime time.Time `cbor:"1,keyasint" json:"genesis_time"`
Params *genParams `cbor:"2,keyasint" json:"params"`
Params *GenParams `cbor:"2,keyasint" json:"params"`
Accounts []genAccount `cbor:"3,keyasint" json:"accounts"`
Validators []genValidator `cbor:"4,keyasint" json:"validators"`
}
Expand All @@ -71,7 +71,7 @@ func (gen *Genesis) GenesisTime() time.Time {
return gen.data.GenesisTime
}

func (gen *Genesis) Params() *genParams {
func (gen *Genesis) Params() *GenParams {
return gen.data.Params
}

Expand Down Expand Up @@ -123,7 +123,7 @@ func makeGenesisValidator(val *validator.Validator) genValidator {
}

func MakeGenesis(genesisTime time.Time, accounts map[crypto.Address]*account.Account,
validators []*validator.Validator, params *genParams,
validators []*validator.Validator, params *GenParams,
) *Genesis {
genAccs := make([]genAccount, len(accounts))
for addr, acc := range accounts {
Expand Down
20 changes: 10 additions & 10 deletions genesis/genesis_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/pactus-project/pactus/types/amount"
)

type genParams struct {
type GenParams struct {
BlockVersion uint8 `cbor:"1,keyasint" json:"block_version"`
BlockIntervalInSecond int `cbor:"2,keyasint" json:"block_interval_in_second"`
CommitteeSize int `cbor:"3,keyasint" json:"committee_size"`
Expand All @@ -15,15 +15,15 @@ type genParams struct {
BondInterval uint32 `cbor:"6,keyasint" json:"bond_interval"`
UnbondInterval uint32 `cbor:"7,keyasint" json:"unbond_interval"`
SortitionInterval uint32 `cbor:"8,keyasint" json:"sortition_interval"`
FeeFraction float64 `cbor:"9,keyasint" json:"fee_fraction"` // Deprecated: Replaced by fix fee
MinimumFee amount.Amount `cbor:"10,keyasint" json:"minimum_fee"` // Deprecated: Replaced by fix fee
MaximumFee amount.Amount `cbor:"11,keyasint" json:"maximum_fee"` // Deprecated: Replaced by fix fee
FeeFraction float64 `cbor:"9,keyasint" json:"fee_fraction"` // Deprecated
MinimumFee amount.Amount `cbor:"10,keyasint" json:"minimum_fee"` // Deprecated
MaximumFee amount.Amount `cbor:"11,keyasint" json:"maximum_fee"` // Deprecated
MinimumStake amount.Amount `cobr:"12,keyasint" json:"minimum_stake"`
MaximumStake amount.Amount `cbor:"13,keyasint" json:"maximum_stake"`
}

func DefaultGenParams() *genParams {
return &genParams{
func DefaultGenParams() *GenParams {
return &GenParams{
BlockVersion: 1,
BlockIntervalInSecond: 10,
CommitteeSize: 51,
Expand All @@ -32,14 +32,14 @@ func DefaultGenParams() *genParams {
BondInterval: 360, // one hour
UnbondInterval: 181440, // 21 days
SortitionInterval: 17,
FeeFraction: 0.0001,
MinimumFee: 1000,
MaximumFee: 1000000,
FeeFraction: 0.0,
MinimumFee: 0,
MaximumFee: 0,
MinimumStake: 1000000000,
MaximumStake: 1000000000000,
}
}

func (p *genParams) BlockInterval() time.Duration {
func (p *GenParams) BlockInterval() time.Duration {
return time.Duration(p.BlockIntervalInSecond) * time.Second
}
22 changes: 11 additions & 11 deletions types/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
)

type Params struct {
BlockVersion uint8 `cbor:"1,keyasint" json:"block_version"`
BlockIntervalInSecond int `cbor:"2,keyasint" json:"block_interval_in_second"`
CommitteeSize int `cbor:"3,keyasint" json:"committee_size"`
BlockReward amount.Amount `cbor:"4,keyasint" json:"block_reward"`
TransactionToLiveInterval uint32 `cbor:"5,keyasint" json:"transaction_to_live_interval"`
BondInterval uint32 `cbor:"6,keyasint" json:"bond_interval"`
UnbondInterval uint32 `cbor:"7,keyasint" json:"unbond_interval"`
SortitionInterval uint32 `cbor:"8,keyasint" json:"sortition_interval"`
MaxTransactionsPerBlock int `cbor:"9,keyasint" json:"max_transaction_per_block"`
MinimumStake amount.Amount `cobr:"10,keyasint" json:"minimum_stake"`
MaximumStake amount.Amount `cbor:"11,keyasint" json:"maximum_stake"`
BlockVersion uint8
BlockIntervalInSecond int
CommitteeSize int
BlockReward amount.Amount
TransactionToLiveInterval uint32
BondInterval uint32
UnbondInterval uint32
SortitionInterval uint32
MaxTransactionsPerBlock int
MinimumStake amount.Amount
MaximumStake amount.Amount
}

func DefaultParams() *Params {
Expand Down

0 comments on commit 83fe68b

Please sign in to comment.