report prints statistics if some number of blocks have been processed or more than a few seconds have passed since the last message.
(chain []*types.Block, index int, cache common.StorageSize)
| 1587 | // report prints statistics if some number of blocks have been processed |
| 1588 | // or more than a few seconds have passed since the last message. |
| 1589 | func (st *insertStats) report(chain []*types.Block, index int, cache common.StorageSize) { |
| 1590 | // Fetch the timings for the batch |
| 1591 | var ( |
| 1592 | now = mclock.Now() |
| 1593 | elapsed = time.Duration(now) - time.Duration(st.startTime) |
| 1594 | ) |
| 1595 | // If we're at the last block of the batch or report period reached, log |
| 1596 | if index == len(chain)-1 || elapsed >= statsReportLimit { |
| 1597 | var ( |
| 1598 | end = chain[index] |
| 1599 | txs = countTransactions(chain[st.lastIndex : index+1]) |
| 1600 | ) |
| 1601 | context := []interface{}{ |
| 1602 | "blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000, |
| 1603 | "elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed), |
| 1604 | "number", end.Number(), "hash", end.Hash().Hex(), "cache", cache, |
| 1605 | } |
| 1606 | if st.queued > 0 { |
| 1607 | context = append(context, []interface{}{"queued", st.queued}...) |
| 1608 | } |
| 1609 | if st.ignored > 0 { |
| 1610 | context = append(context, []interface{}{"ignored", st.ignored}...) |
| 1611 | } |
| 1612 | log.Info("Imported new chain segment", context...) |
| 1613 | |
| 1614 | *st = insertStats{startTime: now, lastIndex: index + 1} |
| 1615 | } |
| 1616 | } |
| 1617 | |
| 1618 | func countTransactions(chain []*types.Block) (c int) { |
| 1619 | for _, b := range chain { |
no test coverage detected