-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(genesis): separating chain param from genesis param (#1463)
- Loading branch information
Showing
18 changed files
with
96 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package param | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/pactus-project/pactus/genesis" | ||
"github.com/pactus-project/pactus/types/amount" | ||
) | ||
|
||
type Params struct { | ||
BlockVersion uint8 | ||
BlockIntervalInSecond int | ||
MaxTransactionsPerBlock int | ||
CommitteeSize int | ||
BlockReward amount.Amount | ||
TransactionToLiveInterval uint32 | ||
BondInterval uint32 | ||
UnbondInterval uint32 | ||
SortitionInterval uint32 | ||
MinimumStake amount.Amount | ||
MaximumStake amount.Amount | ||
} | ||
|
||
func FromGenesis(genDoc *genesis.GenesisParams) *Params { | ||
return &Params{ | ||
// genesis parameters | ||
BlockVersion: genDoc.BlockVersion, | ||
BlockIntervalInSecond: genDoc.BlockIntervalInSecond, | ||
CommitteeSize: genDoc.CommitteeSize, | ||
BlockReward: genDoc.BlockReward, | ||
TransactionToLiveInterval: genDoc.TransactionToLiveInterval, | ||
BondInterval: genDoc.BondInterval, | ||
UnbondInterval: genDoc.UnbondInterval, | ||
SortitionInterval: genDoc.SortitionInterval, | ||
MaximumStake: genDoc.MaximumStake, | ||
MinimumStake: genDoc.MinimumStake, | ||
|
||
// chain parameters | ||
MaxTransactionsPerBlock: 1000, | ||
} | ||
} | ||
|
||
func (p *Params) BlockInterval() time.Duration { | ||
return time.Duration(p.BlockIntervalInSecond) * time.Second | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.