aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@cobinhood.com>2018-10-18 15:47:10 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit308af1ad94b38a3b76b345b3fc6e3e279a97f33b (patch)
treea85b8223a09e25656ff980c58eee6f3aa8311655 /dex
parent6795fe7ac5b8dedf3d1ce7fdfb7f5113d60f0421 (diff)
downloaddexon-308af1ad94b38a3b76b345b3fc6e3e279a97f33b.tar.gz
dexon-308af1ad94b38a3b76b345b3fc6e3e279a97f33b.tar.zst
dexon-308af1ad94b38a3b76b345b3fc6e3e279a97f33b.zip
core/dex: fix governance contract implementation
Diffstat (limited to 'dex')
-rw-r--r--dex/governance.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/dex/governance.go b/dex/governance.go
index 19b9e578c..9235ffce1 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -3,6 +3,7 @@ package dex
import (
"context"
"crypto/ecdsa"
+ "encoding/json"
"math/big"
"time"
@@ -75,7 +76,6 @@ func (d *DexconGovernance) getGovStateAtRound(round uint64) *vm.GovernanceStateH
if state == nil || err != nil {
return nil
}
-
return &vm.GovernanceStateHelper{state}
}
@@ -191,9 +191,9 @@ func (d *DexconGovernance) NotifyRoundHeight(targetRound, consensusHeight uint64
func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *coreTypes.DKGComplaint) {
method := vm.GovernanceContractName2Method["addDKGComplaint"]
- encoded, err := rlp.EncodeToBytes(complaint)
+ encoded, err := json.Marshal(complaint)
if err != nil {
- log.Error("failed to RLP encode complaint to bytes", "err", err)
+ log.Error("failed to JSON encode complaint to bytes", "err", err)
return
}
@@ -214,7 +214,7 @@ func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *coreTypes.DK
func (d *DexconGovernance) DKGComplaints(round uint64) []*coreTypes.DKGComplaint {
s := d.getGovState()
var dkgComplaints []*coreTypes.DKGComplaint
- for _, pk := range s.DKGMasterPublicKeys(big.NewInt(int64(round))) {
+ for _, pk := range s.DKGComplaints(big.NewInt(int64(round))) {
x := new(coreTypes.DKGComplaint)
if err := rlp.DecodeBytes(pk, x); err != nil {
panic(err)
@@ -228,9 +228,9 @@ func (d *DexconGovernance) DKGComplaints(round uint64) []*coreTypes.DKGComplaint
func (d *DexconGovernance) AddDKGMasterPublicKey(round uint64, masterPublicKey *coreTypes.DKGMasterPublicKey) {
method := vm.GovernanceContractName2Method["addDKGMasterPublicKey"]
- encoded, err := rlp.EncodeToBytes(masterPublicKey)
+ encoded, err := json.Marshal(masterPublicKey)
if err != nil {
- log.Error("failed to RLP encode mpk to bytes", "err", err)
+ log.Error("failed to JSON encode mpk to bytes", "err", err)
return
}
@@ -265,9 +265,9 @@ func (d *DexconGovernance) DKGMasterPublicKeys(round uint64) []*coreTypes.DKGMas
func (d *DexconGovernance) AddDKGFinalize(round uint64, final *coreTypes.DKGFinalize) {
method := vm.GovernanceContractName2Method["addDKGFinalize"]
- encoded, err := rlp.EncodeToBytes(final)
+ encoded, err := json.Marshal(final)
if err != nil {
- log.Error("failed to RLP encode finalize to bytes", "err", err)
+ log.Error("failed to JSON encode finalize to bytes", "err", err)
return
}