block: return error from Verify

Don't hide real problem behind the bool value. Makes it easier to identify
problems when looking at log messages.
This commit is contained in:
Roman Khimov 2019-10-11 11:40:54 +03:00
parent 258f397b9a
commit 16bc5296cb
3 changed files with 14 additions and 10 deletions

View file

@ -210,8 +210,9 @@ func (bc *Blockchain) AddBlock(block *Block) error {
return fmt.Errorf("expected block %d, but passed block %d", expectedHeight, block.Index)
}
if bc.verifyBlocks {
if !block.Verify(false) {
return fmt.Errorf("block %s is invalid", block.Hash())
err := block.Verify(false)
if err != nil {
return fmt.Errorf("block %s is invalid: %s", block.Hash().ReverseString(), err)
}
for _, tx := range block.Transactions {
err := bc.Verify(tx)