Created
June 26, 2018 16:09
-
-
Save Nazgolze/f3d40161990b404443a86e5ffdc7652a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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