MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / Sign

Method Sign

xenomint/types/block.go:65–81  ·  view source on GitHub ↗

Sign signs the block.

(signer *asymmetric.PrivateKey)

Source from the content-addressed store, hash-verified

63
64// Sign signs the block.
65func (b *Block) Sign(signer *asymmetric.PrivateKey) (err error) {
66 // Update header fields: generate merkle root from queries
67 var hashes []*hash.Hash
68 for _, v := range b.ReadQueries {
69 h := v.Header.Hash()
70 hashes = append(hashes, &h)
71 }
72 for _, v := range b.WriteQueries {
73 h := v.Header.Hash()
74 hashes = append(hashes, &h)
75 }
76 if err = b.MerkleRoot.SetBytes(merkle.NewMerkle(hashes).GetRoot()[:]); err != nil {
77 return
78 }
79 // Sign block header
80 return b.SignedBlockHeader.Sign(signer)
81}
82
83// Verify verifies the block.
84func (b *Block) Verify() error {

Callers

nothing calls this directly

Calls 5

NewMerkleFunction · 0.92
SetBytesMethod · 0.80
GetRootMethod · 0.80
HashMethod · 0.65
SignMethod · 0.65

Tested by

no test coverage detected