MCPcopy Create free account
hub / github.com/ElementsProject/lightning / maybe_reset_usage_window

Function maybe_reset_usage_window

connectd/multiplex.c:627–638  ·  view source on GitHub ↗

peer->gs's per-second budget: read_hdr_from_peer() and maybe_gossip_msg() * both call this, so whichever notices the window has expired resets it * for both. */

Source from the content-addressed store, hash-verified

625 * both call this, so whichever notices the window has expired resets it
626 * for both. */
627static void maybe_reset_usage_window(struct peer *peer)
628{
629 struct timemono now = time_mono();
630
631 if (time_to_sec(timemono_between(now, peer->gs.window_start)) <= 0)
632 return;
633
634 peer->gs.window_start = now;
635 peer->gs.bytes_rcvd_this_second = 0;
636 peer->gs.bytes_this_second = 0;
637 peer->gs.cpu_usec_this_second = 0;
638}
639
640/* Each peer gets its "fair share" of our query-answering CPU. No floor:
641 * that would let enough peers claim more than the whole budget between

Callers 2

maybe_gossip_msgFunction · 0.85
read_hdr_from_peerFunction · 0.85

Calls 3

time_monoFunction · 0.85
time_to_secFunction · 0.85
timemono_betweenFunction · 0.85

Tested by

no test coverage detected