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

Method getBlock

sqlchain/observer/service.go:641–660  ·  view source on GitHub ↗
(dbID proto.DatabaseID, h *hash.Hash)

Source from the content-addressed store, hash-verified

639}
640
641func (s *Service) getBlock(dbID proto.DatabaseID, h *hash.Hash) (count int32, height int32, b *types.Block, err error) {
642 var blockData []byte
643 err = s.db.Writer().QueryRow(getBlockByHashSQL, string(dbID), h.String()).Scan(&height, &count, &blockData)
644 if err != nil {
645 if errors.Cause(err) == sql.ErrNoRows {
646 err = ErrNotFound
647 return
648 }
649
650 err = errors.Wrapf(err, "query block by hash failed: %s, %s", dbID, h.String())
651 return
652 }
653
654 err = utils.DecodeMsgPack(blockData, &b)
655 if err != nil {
656 err = errors.Wrapf(err, "decode block failed: %s", dbID)
657 }
658
659 return
660}
661
662func (s *Service) getAllSubscriptions() (subscriptions map[proto.DatabaseID]int32, err error) {
663 subscriptions = map[proto.DatabaseID]int32{}

Callers 2

GetBlockMethod · 0.80
GetBlockV3Method · 0.80

Calls 5

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

Tested by

no test coverage detected