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

Function NewInitialBlock

protocol/block.go:242–269  ·  view source on GitHub ↗
(pubkeys []ed25519.PublicKey, nSigs int, timestamp time.Time)

Source from the content-addressed store, hash-verified

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)
244 // so that other packages (e.g. chain/protocol/validation) unit tests can
245 // call this function.
246
247 script, err := vmutil.BlockMultiSigProgram(pubkeys, nSigs)
248 if err != nil {
249 return nil, err
250 }
251
252 root, err := bc.MerkleRoot(nil) // calculate the zero value of the tx merkle root
253 if err != nil {
254 return nil, errors.Wrap(err, "calculating zero value of tx merkle root")
255 }
256
257 b := &legacy.Block{
258 BlockHeader: legacy.BlockHeader{
259 Version: 1,
260 Height: 1,
261 TimestampMS: bc.Millis(timestamp),
262 BlockCommitment: legacy.BlockCommitment{
263 TransactionsMerkleRoot: root,
264 ConsensusProgram: script,
265 },
266 },
267 }
268 return b, nil
269}

Callers 3

TestValidateBlockForSigFunction · 0.85
newTestChainFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestValidateBlockForSigFunction · 0.68
newTestChainFunction · 0.68