MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / addBlock

Function addBlock

blockproducer/storage.go:175–192  ·  view source on GitHub ↗
(height uint32, b *types.BPBlock)

Source from the content-addressed store, hash-verified

173}
174
175func addBlock(height uint32, b *types.BPBlock) storageProcedure {
176 var (
177 enc *bytes.Buffer
178 err error
179 )
180 if enc, err = utils.EncodeMsgPack(b); err != nil {
181 return errPass(err)
182 }
183 return func(tx *sql.Tx) (err error) {
184 _, err = tx.Exec(`INSERT OR REPLACE INTO "blocks" ("height", "hash", "parent", "encoded")
185 VALUES (?, ?, ?, ?)`,
186 height,
187 b.BlockHash().String(),
188 b.ParentHash().String(),
189 enc.Bytes())
190 return
191 }
192}
193
194func addTx(t pi.Transaction) storageProcedure {
195 var (

Callers 3

NewChainWithContextFunction · 0.85
applyBlockMethod · 0.85

Calls 7

EncodeMsgPackFunction · 0.92
errPassFunction · 0.85
ExecMethod · 0.65
StringMethod · 0.45
BlockHashMethod · 0.45
ParentHashMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected