diff options
author | Bojie Wu <bojie@dexon.org> | 2018-10-11 17:54:53 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:49 +0800 |
commit | 8e3c15f4fd150580b5c602bd2d573af72195f801 (patch) | |
tree | 6e92771aadc01049ff4a7f1236dda893b9e2b5be | |
parent | 6502e150041903b8b7e9395c27e4d1b115cff379 (diff) | |
download | dexon-8e3c15f4fd150580b5c602bd2d573af72195f801.tar.gz dexon-8e3c15f4fd150580b5c602bd2d573af72195f801.tar.zst dexon-8e3c15f4fd150580b5c602bd2d573af72195f801.zip |
app: correct validation logic
-rw-r--r-- | dex/app.go | 14 |
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 } |