Skip to content

Instantly share code, notes, and snippets.

@Nazgolze
Created June 26, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nazgolze/f3d40161990b404443a86e5ffdc7652a to your computer and use it in GitHub Desktop.
Save Nazgolze/f3d40161990b404443a86e5ffdc7652a to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import datetime
import logging
import requests
logging.basicConfig(level=logging.DEBUG)
LISK_HOST = 'testnet.lisk.io'
TARGET_HEIGHT = 5594490
SECONDS_IN_A_BLOCK = 10
def get_current_height():
response = requests.get('https://{}/api/blocks/getHeight'.format(LISK_HOST))
assert response.status_code == requests.codes.OK
current_blockheight = response.json().get('height')
logging.debug('Current height: %s', current_blockheight)
return current_blockheight
def get_time_delta():
seconds = (TARGET_HEIGHT - get_current_height()) * SECONDS_IN_A_BLOCK
delta_seconds = datetime.timedelta(seconds=seconds)
return delta_seconds
if __name__ == '__main__':
NOW = datetime.datetime.now()
CUTOFF_DATE = NOW + get_time_delta()
print('Cutoff at {} +/- 10 seconds.'.format(CUTOFF_DATE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment