(ctx context.Context, tx hash.Hash)
| 323 | } |
| 324 | |
| 325 | func 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. |
| 358 | func CreateDatabaseTask(ctx context.Context, _ *config.Config, db *gorp.DbMap, t *model.Task) (r gin.H, err error) { |
no test coverage detected