aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorBojie Wu <bojie@dexon.org>2018-10-11 17:54:53 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 20:54:27 +0800
commit2da6350c8775cdfca8f4284b549ca47a83ad9ab4 (patch)
tree094ab7372c31bf9fcfc960f141e092ae10d9fd37 /dex
parent09f36aa74abce5a14a3b289f9f7ae18346a106e3 (diff)
downloaddexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.tar
dexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.tar.gz
dexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.tar.bz2
dexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.tar.lz
dexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.tar.xz
dexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.tar.zst
dexon-2da6350c8775cdfca8f4284b549ca47a83ad9ab4.zip
app: correct validation logic
Diffstat (limited to 'dex')
-rw-r--r--dex/app.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/dex/app.go b/dex/app.go
index 80384ddc9..cdbcdbda6 100644
--- a/dex/app.go
+++ b/dex/app.go
@@ -19,6 +19,7 @@ package dex
import (
"bytes"
+ "github.com/dexon-foundation/dexon/core/rawdb"
"math/big"
"sync"
"time"
@@ -27,7 +28,6 @@ import (
"github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/core"
- "github.com/dexon-foundation/dexon/core/rawdb"
"github.com/dexon-foundation/dexon/core/state"
"github.com/dexon-foundation/dexon/core/types"
"github.com/dexon-foundation/dexon/core/vm"
@@ -179,8 +179,7 @@ func (d *DexconApp) VerifyBlock(block *coreTypes.Block) bool {
// verify transactions
for _, transaction := range transactions {
- tx, _, _, _ := rawdb.ReadTransaction(d.chainDB, transaction.Hash())
- if tx == nil || d.txPool.ValidateTx(transaction, false) != nil {
+ if d.txPool.ValidateTx(transaction, false) != nil {
return false
}
}
@@ -218,11 +217,18 @@ func (d *DexconApp) VerifyBlock(block *coreTypes.Block) bool {
} else if witnessBlock.ReceiptHash() != witnessData.ReceiptHash {
// invalid receipt root of witness data
return false
- } else if witnessBlock.TxHash() != witnessData.ReceiptHash {
+ } else if witnessBlock.TxHash() != witnessData.TxHash {
// invalid tx root of witness data
return false
}
+ for _, transaction := range witnessBlock.Transactions() {
+ tx, _, _, _ := rawdb.ReadTransaction(d.chainDB, transaction.Hash())
+ if tx == nil {
+ return false
+ }
+ }
+
return true
}