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

Method getHighestBlockV2

sqlchain/observer/service.go:574–595  ·  view source on GitHub ↗
(
	dbID proto.DatabaseID)

Source from the content-addressed store, hash-verified

572}
573
574func (s *Service) getHighestBlockV2(
575 dbID proto.DatabaseID) (count, height int32, b *types.Block, err error,
576) {
577 var blockData []byte
578 err = s.db.Writer().QueryRow(getHighestBlockSQL, string(dbID)).Scan(&height, &count, &blockData)
579 if err != nil {
580 if errors.Cause(err) == sql.ErrNoRows {
581 err = ErrNotFound
582 return
583 }
584
585 err = errors.Wrapf(err, "query highest block failed: %s", dbID)
586 return
587 }
588
589 err = utils.DecodeMsgPack(blockData, &b)
590 if err != nil {
591 err = errors.Wrapf(err, "decode block failed: %s", dbID)
592 }
593
594 return
595}
596
597func (s *Service) getBlockByHeight(dbID proto.DatabaseID, height int32) (count int32, b *types.Block, err error) {
598 var blockData []byte

Callers 2

GetHighestBlockV2Method · 0.80
GetHighestBlockV3Method · 0.80

Calls 4

DecodeMsgPackFunction · 0.92
QueryRowMethod · 0.80
WriterMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected