aboutsummaryrefslogtreecommitdiffstats
path: root/dex/governance.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-02-25 19:35:06 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:22 +0800
commitbfac6dd5391b871d148713014f2694d31d9b6ea4 (patch)
treeb80909c9f5ad6f6021b3ebacff51c73469401765 /dex/governance.go
parent2b2396b6bce0f21b515ac2d38556f6dca08b1770 (diff)
downloadgo-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.tar
go-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.tar.gz
go-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.tar.bz2
go-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.tar.lz
go-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.tar.xz
go-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.tar.zst
go-tangerine-bfac6dd5391b871d148713014f2694d31d9b6ea4.zip
core: vm: flatten governance
Diffstat (limited to 'dex/governance.go')
-rw-r--r--dex/governance.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/dex/governance.go b/dex/governance.go
index 56d08975e..d9cf8fb65 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -67,7 +67,7 @@ func NewDexconGovernance(backend *DexAPIBackend, chainConfig *params.ChainConfig
// DexconConfiguration return raw config in state.
func (d *DexconGovernance) DexconConfiguration(round uint64) *params.DexconConfig {
- return d.GetGovStateHelperAtRound(round).Configuration()
+ return d.GetStateForConfigAtRound(round).Configuration()
}
func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error {
@@ -107,13 +107,32 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error {
// CRS returns the CRS for a given round.
func (d *DexconGovernance) CRS(round uint64) coreCommon.Hash {
- s := d.GetHeadHelper()
- return coreCommon.Hash(s.CRS(big.NewInt(int64(round))))
+ if round <= dexCore.DKGDelayRound {
+ s := d.GetStateAtRound(0)
+ crs := s.CRS()
+ for i := uint64(0); i < round; i++ {
+ crs = crypto.Keccak256Hash(crs[:])
+ }
+ return coreCommon.Hash(crs)
+ }
+ if round > d.CRSRound() {
+ return coreCommon.Hash{}
+ }
+ var s *vm.GovernanceState
+ if round == d.CRSRound() {
+ s = d.GetHeadState()
+ } else {
+ s = d.GetStateAtRound(round)
+ }
+ return coreCommon.Hash(s.CRS())
+}
+
+func (d *DexconGovernance) Round() uint64 {
+ return d.b.CurrentBlock().Round()
}
-func (d *DexconGovernance) LenCRS() uint64 {
- s := d.GetHeadHelper()
- return s.LenCRS().Uint64()
+func (d *DexconGovernance) CRSRound() uint64 {
+ return d.GetHeadState().CRSRound().Uint64()
}
// ProposeCRS send proposals of a new CRS
@@ -132,7 +151,7 @@ func (d *DexconGovernance) ProposeCRS(round uint64, signedCRS []byte) {
// NodeSet returns the current node set.
func (d *DexconGovernance) NodeSet(round uint64) []coreCrypto.PublicKey {
- s := d.GetGovStateHelperAtRound(round)
+ s := d.GetStateForConfigAtRound(round)
var pks []coreCrypto.PublicKey
for _, n := range s.QualifiedNodes() {