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

Function waitForTxState

cmd/cql-proxy/api/database.go:325–355  ·  view source on GitHub ↗
(ctx context.Context, tx hash.Hash)

Source from the content-addressed store, hash-verified

323}
324
325func waitForTxState(ctx context.Context, tx hash.Hash) (state pi.TransactionState, err error) {
326 req := &types.QueryTxStateReq{
327 Hash: tx,
328 }
329
330 for {
331 select {
332 case <-ctx.Done():
333 err = ctx.Err()
334 return
335 case <-time.After(time.Second * 10):
336 resp := &types.QueryTxStateResp{}
337 err = rpc.RequestBP(route.MCCQueryTxState.String(), req, resp)
338 if err != nil {
339 err = errors.Wrapf(err, "query tx %s state failed", tx.String())
340 continue
341 }
342
343 state = resp.State
344
345 switch resp.State {
346 case pi.TransactionStateConfirmed:
347 return
348 case pi.TransactionStateExpired, pi.TransactionStateNotFound:
349 // set error
350 err = errors.Errorf("tx %s expired", tx.String())
351 return
352 }
353 }
354 }
355}
356
357// CreateDatabaseTask handles the database creation process.
358func CreateDatabaseTask(ctx context.Context, _ *config.Config, db *gorp.DbMap, t *model.Task) (r gin.H, err error) {

Callers 4

ApplyTokenTaskFunction · 0.85
CreateDatabaseTaskFunction · 0.85
TopUpTaskFunction · 0.85
CreateProjectTaskFunction · 0.85

Calls 2

ErrorfMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected