271                         if remaining <= ratelimit_period and
ratelimit_period > delay * 2:
272                             min_delay = block_time / dividor
273                             # min_delay + max_delay / 2 = ratelimited_delay
274                             extra_delay = 2 * ratelimited_delay -
3 * min_delay
275                             delay = min_delay + extra_delay * (eta
- mark_time) / ratelimit_period
276  ->                         assert mark_time + delay < eta
(Pdb) p mark_time, delay, mark_time + delay, eta
(1689617957.9965212, 14.028799527978448, 1689617972.0253208, 1689617965.997948)

the code is from a progress bar with automated delay that is used in
loops that query polling-based api endpoints that are waiting for
something slow to happen like a transaction to be mined into a block.

some constraints are:
- the endpoint may not be queried more than ratelimit_count every
ratelimit_period (outside this block, usually delay = ratelimit_period
/ ratelimit_count )
- the code is never called more than once every "delay" seconds

also:
- if a total is known, then as n approaches the total, the endpoint
should be queried close to min_delay = block_time / dividor instead
- things may come up resulting in the code being called at any point
in time at all, but it is always called after an api call
  • [ot][spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
    • Re: [ot... Undescribed Horrific Abuse, One Victim & Survivor of Many
      • Re:... Undescribed Horrific Abuse, One Victim & Survivor of Many
        • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
          • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
            • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
              • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
                • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
                • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
                • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
                • ... Undescribed Horrific Abuse, One Victim & Survivor of Many
                • ... Undescribed Horrific Abuse, One Victim & Survivor of Many

Reply via email to