aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_validator.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-01-24 10:38:28 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:56 +0800
commitbbb1ebede10cd691de4ef2fe4bf276d2fa357a31 (patch)
treec046b5f369c85215761d2db1e4ff890a478ceab4 /core/block_validator.go
parentd79158954a8cea9e14311e9783de82fdbd7a8888 (diff)
downloaddexon-bbb1ebede10cd691de4ef2fe4bf276d2fa357a31.tar.gz
dexon-bbb1ebede10cd691de4ef2fe4bf276d2fa357a31.tar.zst
dexon-bbb1ebede10cd691de4ef2fe4bf276d2fa357a31.zip
core, dex/downloader: polish headers verification and blocks insertion logic (#168)
Refactor GenerateDexonChain function, move governance tx logic to the user of GenerateDexonChain (testchain_test.go) and move fake node set code to FakeDexcon.
Diffstat (limited to 'core/block_validator.go')
-rw-r--r--core/block_validator.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/block_validator.go b/core/block_validator.go
index f42ea6b11..856eec27b 100644
--- a/core/block_validator.go
+++ b/core/block_validator.go
@@ -23,6 +23,7 @@ import (
"github.com/dexon-foundation/dexon/consensus"
"github.com/dexon-foundation/dexon/core/state"
"github.com/dexon-foundation/dexon/core/types"
+ "github.com/dexon-foundation/dexon/log"
"github.com/dexon-foundation/dexon/params"
)
@@ -103,14 +104,16 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
}
func (v *BlockValidator) ValidateWitnessData(height uint64, blockHash common.Hash) error {
- b := v.bc.GetBlockByNumber(height)
+ b := v.bc.GetHeaderByNumber(height)
if b == nil {
- return fmt.Errorf("can not find block %v either pending or confirmed block", height)
+ log.Error("can not find block %v either pending or confirmed block", height)
+ return consensus.ErrWitnessMismatch
}
if b.Hash() != blockHash {
- return fmt.Errorf("invalid witness block %s vs %s",
+ log.Error("invalid witness block %s vs %s",
b.Hash().String(), blockHash.String())
+ return consensus.ErrWitnessMismatch
}
return nil
}