diff options
author | Sonic <sonic@dexon.org> | 2019-01-24 10:38:28 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:21 +0800 |
commit | 51d06935552f8475f95217a268666a8aa24d8a5d (patch) | |
tree | 443413591e4ecd8446fc677800f0a37609162d95 /core/block_validator.go | |
parent | b9defd2cc002d3b5bb3284f9bf11bb08a8e50939 (diff) | |
download | go-tangerine-51d06935552f8475f95217a268666a8aa24d8a5d.tar.gz go-tangerine-51d06935552f8475f95217a268666a8aa24d8a5d.tar.zst go-tangerine-51d06935552f8475f95217a268666a8aa24d8a5d.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.go | 9 |
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 } |