diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-20 16:08:40 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:23:39 +0800 |
commit | 45dee648b6f28f73e781f71a10561dc064327edf (patch) | |
tree | 02bfeeab9f168e782306ab579acedac8e8665de7 /dex/governance.go | |
parent | bd1f04e40e12c36af4df39450489c477c4f0fb06 (diff) | |
download | go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.tar go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.tar.gz go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.tar.bz2 go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.tar.lz go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.tar.xz go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.tar.zst go-tangerine-45dee648b6f28f73e781f71a10561dc064327edf.zip |
dex: use RLP to encode contract payload data
Diffstat (limited to 'dex/governance.go')
-rw-r--r-- | dex/governance.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/dex/governance.go b/dex/governance.go index 17f7f0751..7e6f2b2f6 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -4,7 +4,6 @@ import ( "context" "crypto/ecdsa" "encoding/hex" - "encoding/json" "math/big" "time" @@ -20,6 +19,7 @@ import ( "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/log" "github.com/dexon-foundation/dexon/params" + "github.com/dexon-foundation/dexon/rlp" "github.com/dexon-foundation/dexon/rpc" ) @@ -200,7 +200,7 @@ func (d *DexconGovernance) NotifyRoundHeight(targetRound, consensusHeight uint64 func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *coreTypes.DKGComplaint) { method := vm.GovernanceContractName2Method["addDKGComplaint"] - encoded, err := json.Marshal(complaint) + encoded, err := rlp.EncodeToBytes(complaint) if err != nil { log.Error("failed to JSON encode complaint to bytes", "err", err) return @@ -225,7 +225,7 @@ func (d *DexconGovernance) DKGComplaints(round uint64) []*coreTypes.DKGComplaint var dkgComplaints []*coreTypes.DKGComplaint for _, pk := range s.DKGComplaints(big.NewInt(int64(round))) { x := new(coreTypes.DKGComplaint) - if err := json.Unmarshal(pk, x); err != nil { + if err := rlp.DecodeBytes(pk, x); err != nil { panic(err) } dkgComplaints = append(dkgComplaints, x) @@ -237,7 +237,7 @@ func (d *DexconGovernance) DKGComplaints(round uint64) []*coreTypes.DKGComplaint func (d *DexconGovernance) AddDKGMasterPublicKey(round uint64, masterPublicKey *coreTypes.DKGMasterPublicKey) { method := vm.GovernanceContractName2Method["addDKGMasterPublicKey"] - encoded, err := json.Marshal(masterPublicKey) + encoded, err := rlp.EncodeToBytes(masterPublicKey) if err != nil { log.Error("failed to JSON encode mpk to bytes", "err", err) return @@ -262,7 +262,7 @@ func (d *DexconGovernance) DKGMasterPublicKeys(round uint64) []*coreTypes.DKGMas var dkgMasterPKs []*coreTypes.DKGMasterPublicKey for _, pk := range s.DKGMasterPublicKeys(big.NewInt(int64(round))) { x := new(coreTypes.DKGMasterPublicKey) - if err := json.Unmarshal(pk, x); err != nil { + if err := rlp.DecodeBytes(pk, x); err != nil { panic(err) } dkgMasterPKs = append(dkgMasterPKs, x) @@ -274,7 +274,7 @@ func (d *DexconGovernance) DKGMasterPublicKeys(round uint64) []*coreTypes.DKGMas func (d *DexconGovernance) AddDKGFinalize(round uint64, final *coreTypes.DKGFinalize) { method := vm.GovernanceContractName2Method["addDKGFinalize"] - encoded, err := json.Marshal(final) + encoded, err := rlp.EncodeToBytes(final) if err != nil { log.Error("failed to JSON encode finalize to bytes", "err", err) return |