Skip to content

Instantly share code, notes, and snippets.

@nikkolasg
Created July 13, 2020 19:51
Show Gist options
  • Save nikkolasg/4bb3ba46963ac1152ee4a08652a5da80 to your computer and use it in GitHub Desktop.
Save nikkolasg/4bb3ba46963ac1152ee4a08652a5da80 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from datetime import timedelta
period = 30
catchup = 10
downtime_h = 3
downtime_rounds = 2 * 60 * downtime_h
downtime = period * downtime_rounds
## time to recreate the old beacons
oldCatchup = downtime_rounds * catchup
## time to create the new beacons until we reach the current time
## i.e. how many normal period are there in the oldCatchup time * the period of
## catchup
newCatchup = (oldCatchup / period) * catchup
total = oldCatchup + newCatchup
delta = timedelta(seconds=total)
# pessimistic on the latency
fast_catchup = 0.5
fastOldCatchup = downtime_rounds * fast_catchup
fastNewCatchup = (fastOldCatchup / period) * fast_catchup
fast_total = fastOldCatchup + fastNewCatchup
fast_delta = timedelta(seconds=fast_total)
print("period: %ds" % period)
print("downtime: %d rounds, %ds (%dh)" % (downtime_rounds,downtime,downtime_h))
print("\n-------- With SLOW catchup -----------\n")
print("catchup period: %ds" % catchup)
print("time to catchup \"down\" beacon: %s" % oldCatchup)
print("additional time to catchup the \"new\" beacons: %s" % newCatchup)
print("total time: %ds -> %s" % (total, delta))
print("\n-------- With FAST catchup -----------\n")
print("fast catchup: %fs" % fast_catchup)
print("time to catchup \"down\" beacon: %s" % fastOldCatchup)
print("additional time to catchup the \"new\" beacons: %s" % fastNewCatchup)
print("total time: %ds -> %s" % (fast_total, fast_delta))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment