pushAckedQuery pushes a acknowledged, signed and verified query into the chain.
(ack *types.SignedAckHeader)
| 440 | |
| 441 | // pushAckedQuery pushes a acknowledged, signed and verified query into the chain. |
| 442 | func (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. |
| 468 | func (c *Chain) produceBlock(now time.Time) (err error) { |
no test coverage detected