mirror of
https://github.com/mroxso/timechain-nostr-bot.git
synced 2025-03-17 13:22:02 +01:00
dev2main (#3)
* initial code commit * fixes * fix prints not showing in docker * add github workflow * fix naming of docker image build workflow * add helm chart * fix "connection is already closed" * some big improvements in main script
This commit is contained in:
parent
3632666f1c
commit
59e788c75b
8
main.py
8
main.py
@ -14,20 +14,19 @@ relay_manager.open_connections({"cert_reqs": ssl.CERT_NONE}) # NOTE: This disabl
|
||||
time.sleep(1.25) # allow the connections to open
|
||||
|
||||
env_private_key = os.environ.get("PRIVATE_KEY")
|
||||
# print the value of the environment variable, if it exists
|
||||
if not env_private_key:
|
||||
print('The environment variable "PRIVATE_KEY" is not set.')
|
||||
exit(1)
|
||||
|
||||
private_key = PrivateKey(bytes.fromhex(env_private_key))
|
||||
|
||||
old_block_height = 0
|
||||
while True:
|
||||
old_block_height = 0
|
||||
url = "https://blockchain.info/latestblock"
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
block_height = data["height"]
|
||||
|
||||
|
||||
if(block_height > old_block_height):
|
||||
print("Die aktuelle Bitcoin-Blockhöhe beträgt:", block_height)
|
||||
event = Event(
|
||||
@ -38,4 +37,5 @@ while True:
|
||||
relay_manager.publish_event(event)
|
||||
# relay_manager.close_connections() # NEEDED?!
|
||||
old_block_height = block_height
|
||||
time.sleep(60)
|
||||
time.sleep(5)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user