mirror of
https://github.com/aljazceru/nostrdvm.git
synced 2026-02-09 00:04:21 +01:00
disable relay limits to avoid msising out long contact lists
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
from datetime import timedelta
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, NostrDatabase, \
|
||||
ClientBuilder, Filter, NegentropyOptions, NegentropyDirection, init_logger, LogLevel, Event, EventId, Kind, \
|
||||
RelayOptions
|
||||
RelayOptions, RelayLimits
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils import definitions
|
||||
@@ -88,8 +88,8 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
ns = SimpleNamespace()
|
||||
|
||||
options = DVMTaskInterface.set_options(request_form)
|
||||
|
||||
opts = (Options().wait_for_send(True).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
relaylimits = RelayLimits.disable()
|
||||
opts = (Options().wait_for_send(True).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)).relay_limits(relaylimits))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
@@ -99,7 +99,7 @@ class DicoverContentCurrentlyPopularFollowers(DVMTaskInterface):
|
||||
cli.add_relay("wss://relay.damus.io")
|
||||
cli.add_relay("wss://nos.lol")
|
||||
cli.add_relay("wss://pablof7z.nostr1.com")
|
||||
#add nostr band, too.
|
||||
|
||||
ropts = RelayOptions().ping(False)
|
||||
cli.add_relay_with_opts("wss://nostr.band", ropts)
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ import os
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions, \
|
||||
RelayLimits
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@@ -61,8 +62,8 @@ class DiscoverNonFollowers(DVMTaskInterface):
|
||||
from nostr_sdk import Filter
|
||||
from types import SimpleNamespace
|
||||
ns = SimpleNamespace()
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
relaylimits = RelayLimits.disable()
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)).relay_limits(relaylimits))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
|
||||
@@ -3,7 +3,8 @@ import os
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions, \
|
||||
RelayLimits
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@@ -68,14 +69,38 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
||||
from types import SimpleNamespace
|
||||
ns = SimpleNamespace()
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
|
||||
#relaylimits = RelayLimits()
|
||||
#relaylimits.event_max_num_tags(max_num_tags=None)
|
||||
#relaylimits.event_max_size(None)
|
||||
|
||||
relaylimits = RelayLimits.disable()
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT))).relay_limits(relaylimits)
|
||||
|
||||
|
||||
cli = Client.with_opts(signer, opts)
|
||||
for relay in self.dvm_config.RELAY_LIST:
|
||||
cli.add_relay(relay)
|
||||
|
||||
|
||||
|
||||
cli.add_relay("wss://relay.damus.io")
|
||||
cli.add_relay("wss://nostr21.com")
|
||||
cli.add_relay("wss://nos.lol")
|
||||
cli.add_relay("wss://nostr.mom")
|
||||
cli.add_relay("wss://TheForest.nostr1.com")
|
||||
cli.add_relay("wss://nostr.wine")
|
||||
cli.add_relay("wss://140.f7z.io")
|
||||
cli.add_relay("wss://greensoul.space")
|
||||
ropts = RelayOptions().ping(False)
|
||||
cli.add_relay_with_opts("wss://nostr.band", ropts)
|
||||
|
||||
|
||||
|
||||
#add nostr band, too.
|
||||
ropts = RelayOptions().ping(False)
|
||||
cli.add_relay_with_opts("wss://nostr.band", ropts)
|
||||
@@ -86,7 +111,7 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
||||
step = 20
|
||||
|
||||
followers_filter = Filter().author(PublicKey.parse(options["user"])).kind(Kind(3))
|
||||
followers = cli.get_events_of([followers_filter], timedelta(seconds=self.dvm_config.RELAY_TIMEOUT))
|
||||
followers = cli.get_events_of([followers_filter], timedelta(seconds=10))
|
||||
|
||||
|
||||
if len(followers) > 0:
|
||||
@@ -95,12 +120,16 @@ class DiscoverInactiveFollows(DVMTaskInterface):
|
||||
best_entry = followers[0]
|
||||
for entry in followers:
|
||||
print(len(best_entry.tags()))
|
||||
print(best_entry.created_at().as_secs())
|
||||
if entry.created_at().as_secs() > newest:
|
||||
newest = entry.created_at().as_secs()
|
||||
best_entry = entry
|
||||
|
||||
|
||||
print(best_entry.as_json())
|
||||
print(len(best_entry.tags()))
|
||||
print(best_entry.created_at().as_secs())
|
||||
print(Timestamp.now().as_secs())
|
||||
followings = []
|
||||
ns.dic = {}
|
||||
for tag in best_entry.tags():
|
||||
|
||||
@@ -3,7 +3,8 @@ import os
|
||||
from datetime import timedelta
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions
|
||||
from nostr_sdk import Client, Timestamp, PublicKey, Tag, Keys, Options, SecretKey, NostrSigner, Kind, RelayOptions, \
|
||||
RelayLimits
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@@ -62,8 +63,8 @@ class DiscoverNonFollowers(DVMTaskInterface):
|
||||
from nostr_sdk import Filter
|
||||
from types import SimpleNamespace
|
||||
ns = SimpleNamespace()
|
||||
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)))
|
||||
relaylimits = RelayLimits.disable()
|
||||
opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=self.dvm_config.RELAY_TIMEOUT)).relay_limits(relaylimits))
|
||||
sk = SecretKey.from_hex(self.dvm_config.PRIVATE_KEY)
|
||||
keys = Keys.parse(sk.to_hex())
|
||||
signer = NostrSigner.keys(keys)
|
||||
|
||||
@@ -19,7 +19,7 @@ class DVMConfig:
|
||||
RELAY_LIST = ["wss://relay.damus.io", "wss://nos.lol", "wss://nostr.wine",
|
||||
"wss://nostr.mom", "wss://nostr.oxtr.dev", "wss://relay.nostr.bg",
|
||||
"wss://relay.f7z.io", "wss://pablof7z.nostr1.com", "wss://relay.nostr.net", "wss://140.f7z.io",
|
||||
"wss://relay.snort.social", "wss://offchain.pub/"]
|
||||
]
|
||||
|
||||
RELAY_TIMEOUT = 5
|
||||
EXTERNAL_POST_PROCESS_TYPE = PostProcessFunctionType.NONE # Leave this on None, except the DVM is external
|
||||
|
||||
@@ -5,7 +5,7 @@ from threading import Thread
|
||||
|
||||
import dotenv
|
||||
from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \
|
||||
nip04_encrypt, NostrSigner, PublicKey, Event, Kind
|
||||
nip04_encrypt, NostrSigner, PublicKey, Event, Kind, RelayOptions
|
||||
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nostr_utils import send_event, check_and_set_private_key
|
||||
@@ -125,7 +125,7 @@ def nostr_client_test_censor_filter(users):
|
||||
def nostr_client_test_inactive_filter(user):
|
||||
keys = Keys.parse(check_and_set_private_key("test_client"))
|
||||
|
||||
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz", "wss://relayable.org",
|
||||
relay_list = ["wss://relay.damus.io", "wss://blastr.f7z.xyz",
|
||||
]
|
||||
|
||||
relaysTag = Tag.parse(relay_list)
|
||||
@@ -143,6 +143,8 @@ def nostr_client_test_inactive_filter(user):
|
||||
client = Client(signer)
|
||||
for relay in relay_list:
|
||||
client.add_relay(relay)
|
||||
ropts = RelayOptions().ping(False)
|
||||
client.add_relay_with_opts("wss://nostr.band", ropts)
|
||||
client.connect()
|
||||
config = DVMConfig
|
||||
send_event(event, client=client, dvm_config=config)
|
||||
|
||||
Reference in New Issue
Block a user