(count, height int32, b *types.Block, pagination *paginationOps)
| 472 | } |
| 473 | |
| 474 | func (a *explorerAPI) formatBlockV3(count, height int32, b *types.Block, |
| 475 | pagination *paginationOps) (res map[string]interface{}) { |
| 476 | res = a.formatBlockV2(count, height, b) |
| 477 | blockRes := res["block"].(map[string]interface{}) |
| 478 | blockRes["queries"] = func() (tracks []interface{}) { |
| 479 | tracks = make([]interface{}, 0, len(b.QueryTxs)+len(b.FailedReqs)) |
| 480 | |
| 481 | var ( |
| 482 | offset = (pagination.page - 1) * pagination.size |
| 483 | end = pagination.page * pagination.size |
| 484 | pos = 0 |
| 485 | ) |
| 486 | |
| 487 | for _, tx := range b.QueryTxs { |
| 488 | if (pagination.queryType == types.ReadQuery || pagination.queryType == types.WriteQuery) && |
| 489 | tx.Request.Header.QueryType != pagination.queryType { |
| 490 | // count all |
| 491 | continue |
| 492 | } |
| 493 | |
| 494 | if pos >= end { |
| 495 | return |
| 496 | } |
| 497 | |
| 498 | t := a.formatRequest(tx.Request) |
| 499 | t["response"] = a.formatResponseHeader(tx.Response)["response"] |
| 500 | t["failed"] = false |
| 501 | |
| 502 | if pos >= offset { |
| 503 | tracks = append(tracks, t) |
| 504 | } |
| 505 | |
| 506 | pos++ |
| 507 | } |
| 508 | |
| 509 | for _, req := range b.FailedReqs { |
| 510 | if (pagination.queryType == types.ReadQuery || pagination.queryType == types.WriteQuery) && |
| 511 | req.Header.QueryType != pagination.queryType { |
| 512 | // count all |
| 513 | continue |
| 514 | } |
| 515 | |
| 516 | if pos >= end { |
| 517 | return |
| 518 | } |
| 519 | |
| 520 | t := a.formatRequest(req) |
| 521 | t["failed"] = true |
| 522 | |
| 523 | if pos >= offset { |
| 524 | tracks = append(tracks, t) |
| 525 | } |
| 526 | |
| 527 | pos++ |
| 528 | } |
| 529 | |
| 530 | return |
| 531 | }() |
no test coverage detected