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

Function buildQueryEx

worker/db_test.go:611–655  ·  view source on GitHub ↗
(queryType types.QueryType, connID uint64, seqNo uint64, timeShift time.Duration, databaseID proto.DatabaseID, queries []string)

Source from the content-addressed store, hash-verified

609}
610
611func buildQueryEx(queryType types.QueryType, connID uint64, seqNo uint64, timeShift time.Duration, databaseID proto.DatabaseID, queries []string) (query *types.Request, err error) {
612 // get node id
613 var nodeID proto.NodeID
614 if nodeID, err = kms.GetLocalNodeID(); err != nil {
615 return
616 }
617
618 // get private/public key
619 var privateKey *asymmetric.PrivateKey
620
621 if privateKey, _, err = getKeys(); err != nil {
622 return
623 }
624
625 tm := getLocalTime()
626 tm = tm.Add(-timeShift)
627
628 // build queries
629 realQueries := make([]types.Query, len(queries))
630
631 for i, v := range queries {
632 realQueries[i].Pattern = v
633 }
634
635 query = &types.Request{
636 Header: types.SignedRequestHeader{
637 RequestHeader: types.RequestHeader{
638 DatabaseID: databaseID,
639 QueryType: queryType,
640 NodeID: nodeID,
641 ConnectionID: connID,
642 SeqNo: seqNo,
643 Timestamp: tm,
644 },
645 },
646 Payload: types.RequestPayload{
647 Queries: realQueries,
648 },
649 }
650 query.SetContext(context.Background())
651
652 err = query.Sign(privateKey)
653
654 return
655}
656
657func getPeers(term uint64) (peers *proto.Peers, err error) {
658 // get node id

Callers 3

buildQueryFunction · 0.85
buildQueryWithDatabaseIDFunction · 0.85
buildQueryWithTimeShiftFunction · 0.85

Calls 6

GetLocalNodeIDFunction · 0.92
getKeysFunction · 0.70
getLocalTimeFunction · 0.70
SetContextMethod · 0.65
SignMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected