MCPcopy Index your code
hub / github.com/chain/Core / ValidateBlockForSig

Method ValidateBlockForSig

protocol/block.go:227–240  ·  view source on GitHub ↗

ValidateBlockForSig performs validation on an incoming _unsigned_ block in preparation for signing it. By definition it does not execute the consensus program.

(ctx context.Context, block *legacy.Block)

Source from the content-addressed store, hash-verified

225// block in preparation for signing it. By definition it does not
226// execute the consensus program.
227func (c *Chain) ValidateBlockForSig(ctx context.Context, block *legacy.Block) error {
228 var prev *legacy.Block
229
230 if block.Height > 1 {
231 var err error
232 prev, err = c.GetBlock(ctx, block.Height-1)
233 if err != nil {
234 return errors.Wrap(err, "getting previous block")
235 }
236 }
237
238 err := validation.ValidateBlock(legacy.MapBlock(block), legacy.MapBlock(prev), c.InitialBlockHash, c.ValidateTx)
239 return errors.Sub(ErrBadBlock, err)
240}
241
242func NewInitialBlock(pubkeys []ed25519.PublicKey, nSigs int, timestamp time.Time) (*legacy.Block, error) {
243 // TODO(kr): move this into a lower-level package (e.g. chain/protocol/bc)

Callers 3

TestValidateBlockForSigFunction · 0.95
ValidateAndSignBlockMethod · 0.80

Calls 3

GetBlockMethod · 0.95
ValidateBlockMethod · 0.80
SubMethod · 0.45

Tested by 2

TestValidateBlockForSigFunction · 0.76