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-03-12 12:19:09 +0800
commitd711fef2d53b6dd8f55060c8463f7b38716c44c7 (patch)
tree63188050bf046618df515f71f3c5d5c6b59b0f8f /core/block_validator.go
parente8f768ccdbe2c7f5039153f6c6e7c2b668831fb2 (diff)
downloaddexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.tar
dexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.tar.gz
dexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.tar.bz2
dexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.tar.lz
dexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.tar.xz
dexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.tar.zst
dexon-d711fef2d53b6dd8f55060c8463f7b38716c44c7.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
}