forked from TrueCloudLab/neoneo-go
core: verify transactions in AddBlock()
This commit is contained in:
parent
1095abb04c
commit
854fb187a3
1 changed files with 10 additions and 2 deletions
|
@ -207,9 +207,17 @@ func (bc *Blockchain) AddBlock(block *Block) error {
|
||||||
if expectedHeight != block.Index {
|
if expectedHeight != block.Index {
|
||||||
return fmt.Errorf("expected block %d, but passed block %d", expectedHeight, block.Index)
|
return fmt.Errorf("expected block %d, but passed block %d", expectedHeight, block.Index)
|
||||||
}
|
}
|
||||||
if bc.verifyBlocks && !block.Verify(false) {
|
if bc.verifyBlocks {
|
||||||
|
if !block.Verify(false) {
|
||||||
return fmt.Errorf("block %s is invalid", block.Hash())
|
return fmt.Errorf("block %s is invalid", block.Hash())
|
||||||
}
|
}
|
||||||
|
for _, tx := range block.Transactions {
|
||||||
|
err := bc.Verify(tx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("transaction %s failed to verify: %s", tx.Hash().ReverseString(), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
headerLen := bc.headerListLen()
|
headerLen := bc.headerListLen()
|
||||||
if int(block.Index) == headerLen {
|
if int(block.Index) == headerLen {
|
||||||
err := bc.AddHeaders(block.Header())
|
err := bc.AddHeaders(block.Header())
|
||||||
|
|
Loading…
Reference in a new issue