From b0a60baf22729665cc4b52cd1f0b2aa4e479f684 Mon Sep 17 00:00:00 2001 From: Bojie Wu Date: Thu, 11 Oct 2018 17:54:53 +0800 Subject: app: correct validation logic --- dex/app.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'dex') 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 } -- cgit v1.2.3