| 1554 | } |
| 1555 | } |
| 1556 | void node_impl::bandwidth_monitor_loop() |
| 1557 | { |
| 1558 | VERIFY_CORRECT_THREAD(); |
| 1559 | fc::time_point_sec current_time = fc::time_point::now(); |
| 1560 | |
| 1561 | if (_bandwidth_monitor_last_update_time == fc::time_point_sec::min()) |
| 1562 | _bandwidth_monitor_last_update_time = current_time; |
| 1563 | |
| 1564 | uint32_t seconds_since_last_update = current_time.sec_since_epoch() - _bandwidth_monitor_last_update_time.sec_since_epoch(); |
| 1565 | seconds_since_last_update = std::max(UINT32_C(1), seconds_since_last_update); |
| 1566 | uint32_t bytes_read_this_second = _rate_limiter.get_actual_download_rate(); |
| 1567 | uint32_t bytes_written_this_second = _rate_limiter.get_actual_upload_rate(); |
| 1568 | for (uint32_t i = 0; i < seconds_since_last_update - 1; ++i) |
| 1569 | update_bandwidth_data(0, 0); |
| 1570 | update_bandwidth_data(bytes_read_this_second, bytes_written_this_second); |
| 1571 | _bandwidth_monitor_last_update_time = current_time; |
| 1572 | |
| 1573 | if (!_node_is_shutting_down && !_bandwidth_monitor_loop_done.canceled()) |
| 1574 | _bandwidth_monitor_loop_done = fc::schedule( [=](){ bandwidth_monitor_loop(); }, |
| 1575 | fc::time_point::now() + fc::seconds(1), |
| 1576 | "bandwidth_monitor_loop" ); |
| 1577 | } |
| 1578 | |
| 1579 | void node_impl::dump_node_status_task() |
| 1580 | { |