mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-03-17 21:31:52 +01:00
add uniffi_set_event_loop
This commit is contained in:
parent
9fec528723
commit
01513747a8
@ -6,7 +6,7 @@ from datetime import timedelta
|
||||
|
||||
from nostr_sdk import (Keys, Client, Timestamp, Filter, nip04_decrypt, HandleNotification, EventBuilder, PublicKey,
|
||||
Options, Tag, Event, nip04_encrypt, NostrSigner, EventId, Nip19Event, Kind, KindEnum,
|
||||
UnsignedEvent, UnwrappedGift)
|
||||
UnsignedEvent, UnwrappedGift, uniffi_set_event_loop)
|
||||
|
||||
from nostr_dvm.utils.admin_utils import admin_make_database_updates
|
||||
from nostr_dvm.utils.cashu_utils import redeem_cashu
|
||||
@ -29,6 +29,7 @@ class Bot:
|
||||
|
||||
def __init__(self, dvm_config, admin_config=None):
|
||||
asyncio.run(self.run_bot(dvm_config, admin_config))
|
||||
uniffi_set_event_loop(asyncio.get_running_loop())
|
||||
|
||||
# add_sql_table_column(dvm_config.DB)
|
||||
|
||||
|
@ -4,7 +4,7 @@ import os
|
||||
from sys import platform
|
||||
|
||||
from nostr_sdk import PublicKey, Keys, Client, Tag, Event, EventBuilder, Filter, HandleNotification, Timestamp, \
|
||||
LogLevel, Options, nip04_encrypt, Kind, RelayLimits
|
||||
LogLevel, Options, nip04_encrypt, Kind, RelayLimits, uniffi_set_event_loop
|
||||
|
||||
from nostr_dvm.utils.admin_utils import admin_make_database_updates, AdminConfig
|
||||
from nostr_dvm.utils.backend_utils import get_amount_per_task, check_task_is_supported, get_task
|
||||
@ -25,6 +25,7 @@ from nostr_dvm.utils.zap_utils import check_bolt11_ln_bits_is_paid, create_bolt1
|
||||
|
||||
#os.environ["RUST_BACKTRACE"] = "full"
|
||||
|
||||
|
||||
class DVM:
|
||||
dvm_config: DVMConfig
|
||||
admin_config: AdminConfig
|
||||
@ -35,6 +36,7 @@ class DVM:
|
||||
|
||||
def __init__(self, dvm_config, admin_config=None):
|
||||
asyncio.run(self.run_dvm(dvm_config, admin_config))
|
||||
uniffi_set_event_loop(asyncio.get_running_loop())
|
||||
|
||||
async def run_dvm(self, dvm_config, admin_config):
|
||||
|
||||
@ -856,6 +858,9 @@ class DVM:
|
||||
|
||||
asyncio.create_task(self.client.handle_notifications(NotificationHandler()))
|
||||
|
||||
|
||||
|
||||
|
||||
while True:
|
||||
for dvm in self.dvm_config.SUPPORTED_DVMS:
|
||||
await dvm.schedule(self.dvm_config)
|
||||
|
@ -6,7 +6,7 @@ import signal
|
||||
from datetime import timedelta
|
||||
|
||||
from nostr_sdk import (Keys, Client, Timestamp, Filter, nip04_decrypt, HandleNotification, EventBuilder, PublicKey,
|
||||
Options, Tag, Event, nip04_encrypt, NostrSigner, EventId)
|
||||
Options, Tag, Event, nip04_encrypt, NostrSigner, EventId, uniffi_set_event_loop)
|
||||
|
||||
from nostr_dvm.utils.database_utils import fetch_user_metadata
|
||||
from nostr_dvm.utils.definitions import EventDefinitions, relay_timeout
|
||||
@ -27,6 +27,7 @@ class Subscription:
|
||||
# This is a simple list just to keep track which events we created and manage, so we don't pay for other requests
|
||||
def __init__(self, dvm_config, admin_config=None):
|
||||
asyncio.run(self.run_subscription(dvm_config, admin_config))
|
||||
uniffi_set_event_loop(asyncio.get_running_loop())
|
||||
|
||||
async def run_subscription(self, dvm_config, admin_config):
|
||||
|
||||
|
@ -38,7 +38,7 @@ update_profile = False
|
||||
global_update_rate = 180 # set this high on first sync so db can fully sync before another process trys to.
|
||||
use_logger = True
|
||||
log_level = LogLevel.ERROR
|
||||
max_sync_duration_in_h = 6
|
||||
max_sync_duration_in_h = 48
|
||||
|
||||
|
||||
SYNC_DB_RELAY_LIST = [ "wss://relay.damus.io",
|
||||
@ -536,8 +536,8 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
|
||||
dvm_config.UPDATE_DATABASE = update_db
|
||||
dvm_config.AVOID_OUTBOX_RELAY_LIST = AVOID_OUTBOX_RELAY_LIST
|
||||
dvm_config.RELAY_LIST = RELAY_LIST
|
||||
#dvm_config.SYNC_DB_RELAY_LIST = ["wss://nfrelay.app/?user=activitypub"]
|
||||
dvm_config.SYNC_DB_RELAY_LIST = ["wss://relay.momostr.pink", "wss://relay.mostr.pub/"]
|
||||
dvm_config.SYNC_DB_RELAY_LIST = ["wss://nfrelay.app/?user=activitypub"]
|
||||
#dvm_config.SYNC_DB_RELAY_LIST = ["wss://relay.mostr.pub/"]
|
||||
|
||||
dvm_config.FIX_COST = cost
|
||||
dvm_config.CUSTOM_PROCESSING_MESSAGE = processing_msg
|
||||
@ -803,16 +803,17 @@ def playground():
|
||||
}
|
||||
cost = 0
|
||||
image = "https://i.nostr.build/mtkNd3J8m0mqj9nq.jpg"
|
||||
discovery_mostr = build_example_mostr("Trending on Mostr",
|
||||
"discovery_mostr",
|
||||
admin_config=admin_config_mostr,
|
||||
options=options_mostr,
|
||||
image=image,
|
||||
cost=cost,
|
||||
update_rate=180,
|
||||
processing_msg=custom_processing_msg,
|
||||
update_db=True)
|
||||
discovery_mostr.run()
|
||||
#discovery_mostr = build_example_mostr("Trending on Mostr",
|
||||
# "discovery_mostr",
|
||||
#
|
||||
# admin_config=admin_config_mostr,
|
||||
# options=options_mostr,
|
||||
# image=image,
|
||||
# cost=cost,
|
||||
# update_rate=180,
|
||||
# processing_msg=custom_processing_msg,
|
||||
# update_db=True)
|
||||
#discovery_mostr.run()
|
||||
|
||||
# Popular Garden&Plants
|
||||
admin_config_asknostr = AdminConfig()
|
||||
@ -1065,7 +1066,7 @@ def playground():
|
||||
update_db = True
|
||||
|
||||
options_opf = {
|
||||
"db_name": "db/nostr_mostr.db",
|
||||
"db_name": "db/nostr_recent_notes.db",
|
||||
"db_since": 60 * 60 * 2, # 1h since gmt,
|
||||
}
|
||||
cost = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user