mirror of
https://github.com/aljazceru/nostrdvm.git
synced 2026-01-27 01:44:36 +01:00
move examples from playground to modules
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import typing
|
||||
import os
|
||||
import signal
|
||||
import time
|
||||
|
||||
import requests
|
||||
from nostr_sdk import Event, Tag
|
||||
@@ -184,3 +186,13 @@ def get_amount_per_task(task, dvm_config, duration=1):
|
||||
print("[" + dvm_config.SUPPORTED_DVMS[
|
||||
0].NAME + "] Task " + task + " is currently not supported by this instance, skipping")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def keep_alive():
|
||||
try:
|
||||
while True:
|
||||
time.sleep(10)
|
||||
except KeyboardInterrupt:
|
||||
os.kill(os.getpid(), signal.SIGKILL)
|
||||
exit(1)
|
||||
@@ -318,3 +318,20 @@ def redeem_cashu(cashu, required_amount, config, client) -> (bool, str):
|
||||
print(e)
|
||||
|
||||
return False, ""
|
||||
|
||||
def get_price_per_sat(currency):
|
||||
import requests
|
||||
|
||||
url = "https://api.coinstats.app/public/v1/coins"
|
||||
params = {"skip": 0, "limit": 1, "currency": currency}
|
||||
try:
|
||||
response = requests.get(url, params=params)
|
||||
response_json = response.json()
|
||||
|
||||
bitcoin_price = response_json["coins"][0]["price"]
|
||||
price_currency_per_sat = bitcoin_price / 100000000.0
|
||||
except:
|
||||
price_currency_per_sat = 0.0004
|
||||
|
||||
return price_currency_per_sat
|
||||
|
||||
|
||||
Reference in New Issue
Block a user