Query queries req from local chain state and returns the query results in resp.
(req *types.Request)
| 61 | |
| 62 | // Query queries req from local chain state and returns the query results in resp. |
| 63 | func (c *Chain) Query(req *types.Request) (resp *types.Response, err error) { |
| 64 | var ( |
| 65 | ref *QueryTracker |
| 66 | start = time.Now() |
| 67 | |
| 68 | queried, signed, updated time.Duration |
| 69 | ) |
| 70 | defer func() { |
| 71 | var fields = log.Fields{} |
| 72 | if queried > 0 { |
| 73 | fields["1#queried"] = float64(queried.Nanoseconds()) / 1000 |
| 74 | } |
| 75 | if signed > 0 { |
| 76 | fields["2#signed"] = float64((signed - queried).Nanoseconds()) / 1000 |
| 77 | } |
| 78 | if updated > 0 { |
| 79 | fields["3#updated"] = float64((updated - signed).Nanoseconds()) / 1000 |
| 80 | } |
| 81 | log.WithFields(fields).Debug("Chain.Query duration stat (us)") |
| 82 | }() |
| 83 | if ref, resp, err = c.state.Query(req, true); err != nil { |
| 84 | return |
| 85 | } |
| 86 | queried = time.Since(start) |
| 87 | if err = resp.BuildHash(); err != nil { |
| 88 | return |
| 89 | } |
| 90 | signed = time.Since(start) |
| 91 | ref.UpdateResp(resp) |
| 92 | updated = time.Since(start) |
| 93 | return |
| 94 | } |
| 95 | |
| 96 | // Stop stops chain workers and RPC service. |
| 97 | func (c *Chain) Stop() (err error) { |
nothing calls this directly
no test coverage detected