split verifyAndInsertBlock function to be able to reuse verification part

pull/4465/head
“GheisMohammadi” 1 year ago
parent 498bcc0416
commit 1f26944a33
No known key found for this signature in database
GPG Key ID: 15073AED3829FE90
  1. 13
      api/service/stagedstreamsync/sig_verify.go

@ -29,7 +29,7 @@ func verifyAndInsertBlocks(bc blockChain, blocks types.Blocks, blockExecution bo
return len(blocks), nil
}
func verifyAndInsertBlock(bc blockChain, block *types.Block, blockExecution bool, nextBlocks ...*types.Block) error {
func verifyBlock(bc blockChain, block *types.Block, nextBlocks ...*types.Block) error {
var (
sigBytes bls.SerializedSignature
bitmap []byte
@ -61,7 +61,18 @@ func verifyAndInsertBlock(bc blockChain, block *types.Block, blockExecution bool
case err != nil:
return errors.Wrap(err, "[InsertChain]")
default:
}
return nil
}
func verifyAndInsertBlock(bc blockChain, block *types.Block, blockExecution bool, nextBlocks ...*types.Block) error {
//verify block
if err := verifyBlock(bc, block, nextBlocks...); err != nil {
return err
}
// insert block
if _, err := bc.InsertChain(types.Blocks{block}, false, blockExecution); err != nil {
return errors.Wrap(err, "[InsertChain]")
}
return nil
}

Loading…
Cancel
Save