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

Method pushAckedQuery

sqlchain/chain.go:442–465  ·  view source on GitHub ↗

pushAckedQuery pushes a acknowledged, signed and verified query into the chain.

(ack *types.SignedAckHeader)

Source from the content-addressed store, hash-verified

440
441// pushAckedQuery pushes a acknowledged, signed and verified query into the chain.
442func (c *Chain) pushAckedQuery(ack *types.SignedAckHeader) (err error) {
443 log.WithField("db", c.databaseID).Debugf("push ack %s", ack.Hash().String())
444 h := c.rt.getHeightFromTime(ack.GetResponseTimestamp())
445 k := heightToKey(h)
446 var enc *bytes.Buffer
447
448 if enc, err = utils.EncodeMsgPack(ack); err != nil {
449 return
450 }
451
452 tdbKey := utils.ConcatAll(c.metaAckIndex, k, ack.Hash().AsBytes())
453
454 if err = c.register(ack); err != nil {
455 err = errors.Wrapf(err, "register ack %v at height %d", ack.Hash(), h)
456 return
457 }
458
459 if err = txDB.Put(tdbKey, enc.Bytes(), nil); err != nil {
460 err = errors.Wrapf(err, "put ack %d %s", h, ack.Hash().String())
461 return
462 }
463
464 return
465}
466
467// produceBlock prepares, signs and advises the pending block to the other peers.
468func (c *Chain) produceBlock(now time.Time) (err error) {

Callers 1

Calls 13

registerMethod · 0.95
WithFieldFunction · 0.92
EncodeMsgPackFunction · 0.92
ConcatAllFunction · 0.92
heightToKeyFunction · 0.85
DebugfMethod · 0.80
getHeightFromTimeMethod · 0.80
GetResponseTimestampMethod · 0.80
AsBytesMethod · 0.80
PutMethod · 0.80
HashMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected