aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-12-19 10:22:38 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:19 +0800
commit688f2f832e7513cedbd7f51bced6ed76348e2b2f (patch)
treea0f7a7f9de36f249c3e06713740bcb292d5f90a7 /dex
parentc399c2fbf2000313ff32f8e1f9b1839f157a8b97 (diff)
downloadgo-tangerine-688f2f832e7513cedbd7f51bced6ed76348e2b2f.tar.gz
go-tangerine-688f2f832e7513cedbd7f51bced6ed76348e2b2f.tar.zst
go-tangerine-688f2f832e7513cedbd7f51bced6ed76348e2b2f.zip
dex: remove duplicate declaration of WitnessData (#92)
Remove duplicate declaration of WitnessData and remove the TxHash field in witness data since it does not need to be witnessed.
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go11
-rw-r--r--dex/app_test.go6
2 files changed, 3 insertions, 14 deletions
diff --git a/dex/app.go b/dex/app.go
index 8da00d07b..9dcfd87e9 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -50,12 +50,6 @@ type DexconApp struct {
chainLocks sync.Map
}
-type witnessData struct {
- Root common.Hash
- TxHash common.Hash
- ReceiptHash common.Hash
-}
-
func NewDexconApp(txPool *core.TxPool, blockchain *core.BlockChain, gov *DexconGovernance,
chainDB ethdb.Database, config *Config) *DexconApp {
return &DexconApp{
@@ -283,9 +277,8 @@ func (d *DexconApp) PrepareWitness(consensusHeight uint64) (witness coreTypes.Wi
return witness, fmt.Errorf("last pending height < consensus height")
}
- witnessData, err := rlp.EncodeToBytes(&witnessData{
+ witnessData, err := rlp.EncodeToBytes(&types.WitnessData{
Root: witnessBlock.Root(),
- TxHash: witnessBlock.TxHash(),
ReceiptHash: witnessBlock.ReceiptHash(),
})
if err != nil {
@@ -300,7 +293,7 @@ func (d *DexconApp) PrepareWitness(consensusHeight uint64) (witness coreTypes.Wi
// VerifyBlock verifies if the payloads are valid.
func (d *DexconApp) VerifyBlock(block *coreTypes.Block) coreTypes.BlockVerifyStatus {
- var witnessData witnessData
+ var witnessData types.WitnessData
err := rlp.DecodeBytes(block.Witness.Data, &witnessData)
if err != nil {
log.Error("failed to RLP decode witness data", "error", err)
diff --git a/dex/app_test.go b/dex/app_test.go
index abe83b92a..82bf8a6f6 100644
--- a/dex/app_test.go
+++ b/dex/app_test.go
@@ -115,16 +115,12 @@ func TestPrepareWitness(t *testing.T) {
t.Errorf("unexpeted witness height %v", witness.Height)
}
- var witnessData witnessData
+ var witnessData types.WitnessData
err = rlp.DecodeBytes(witness.Data, &witnessData)
if err != nil {
t.Errorf("rlp decode error: %v", err)
}
- if witnessData.TxHash != currentBlock.TxHash() {
- t.Errorf("expect tx hash %v but %v", currentBlock.TxHash(), witnessData.TxHash)
- }
-
if witnessData.Root != currentBlock.Root() {
t.Errorf("expect root %v but %v", currentBlock.Root(), witnessData.Root)
}