mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-20 00:26:31 +01:00
optimizations top zaps
This commit is contained in:
@@ -135,25 +135,50 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
|
|||||||
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP]).event(event.id()).since(since)
|
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP]).event(event.id()).since(since)
|
||||||
zaps = await database.query([filt])
|
zaps = await database.query([filt])
|
||||||
invoice_amount = 0
|
invoice_amount = 0
|
||||||
|
event_author = event.author().to_hex()
|
||||||
if len(zaps) >= self.min_reactions:
|
if len(zaps) >= self.min_reactions:
|
||||||
has_preimage = False
|
has_preimage = False
|
||||||
|
has_amount = False
|
||||||
overall_amount = 0
|
overall_amount = 0
|
||||||
for zap in zaps:
|
for zap in zaps:
|
||||||
if event.author().to_hex() == zap.author().to_hex():
|
if event_author == zap.author().to_hex():
|
||||||
continue #Skip self zaps..
|
continue #Skip self zaps..
|
||||||
invoice_amount = 0
|
invoice_amount = 0
|
||||||
for tag in zap.tags():
|
for tag in zap.tags():
|
||||||
# print(tag.as_vec())
|
|
||||||
if tag.as_vec()[0] == 'bolt11':
|
if tag.as_vec()[0] == 'bolt11':
|
||||||
# print(tag.as_vec()[1])
|
# print(tag.as_vec()[1])
|
||||||
invoice_amount = parse_amount_from_bolt11_invoice(tag.as_vec()[1])
|
invoice_amount = parse_amount_from_bolt11_invoice(tag.as_vec()[1])
|
||||||
|
|
||||||
|
has_amount = True
|
||||||
|
if has_preimage:
|
||||||
|
break
|
||||||
# print(invoice_amount)
|
# print(invoice_amount)
|
||||||
if tag.as_vec()[0] == 'preimage':
|
if tag.as_vec()[0] == 'preimage':
|
||||||
if len(tag.as_vec()) > 1:
|
if len(tag.as_vec()) > 1:
|
||||||
if tag.as_vec()[1] != "":
|
if tag.as_vec()[1] == "":
|
||||||
overall_amount += invoice_amount
|
continue
|
||||||
|
elif tag.as_vec()[1] != "":
|
||||||
|
|
||||||
has_preimage = True # TODO further check preimage
|
has_preimage = True # TODO further check preimage
|
||||||
|
if has_amount:
|
||||||
|
overall_amount += invoice_amount
|
||||||
|
break
|
||||||
|
#elif tag.as_vec()[0] == 'description':
|
||||||
|
# try:
|
||||||
|
# event = Event.from_json(tag.as_vec()[1])
|
||||||
|
# for tag in event.tags():
|
||||||
|
# if tag.as_vec()[0] == "amount":
|
||||||
|
# invoice_amount = tag.as_vec()[1]
|
||||||
|
# overall_amount += invoice_amount
|
||||||
|
|
||||||
|
# has_amount = True
|
||||||
|
# if has_preimage:
|
||||||
|
# break
|
||||||
|
|
||||||
|
# except:
|
||||||
|
# pass
|
||||||
|
|
||||||
if has_preimage:
|
if has_preimage:
|
||||||
ns.finallist[event.id().to_hex()] = overall_amount
|
ns.finallist[event.id().to_hex()] = overall_amount
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ use_logger = True
|
|||||||
AVOID_PAID_OUTBOX_RELAY_LIST = ["wss://nostrelay.yeghro.site", "wss://nostr.wine", "wss://filter.nostr.wine"
|
AVOID_PAID_OUTBOX_RELAY_LIST = ["wss://nostrelay.yeghro.site", "wss://nostr.wine", "wss://filter.nostr.wine"
|
||||||
"wss://nostr21.com", "wss://nostr.bitcoiner.social", "wss://nostr.orangepill.dev",
|
"wss://nostr21.com", "wss://nostr.bitcoiner.social", "wss://nostr.orangepill.dev",
|
||||||
"wss://relay.lnpay.me", "wss://relay.snort.social", "wss://relay.minds.com/nostr/v1/ws",
|
"wss://relay.lnpay.me", "wss://relay.snort.social", "wss://relay.minds.com/nostr/v1/ws",
|
||||||
"wss://nostr-pub.semisol.dev", "wss://mostr.pub", "wss://relay.mostr.pub", "wss://minds.com",
|
"wss://nostr-pub.semisol.dev", "wss://mostr.mostr.pub", "wss://relay.mostr.pub", "wss://minds.com",
|
||||||
"wss://yabu.me", "wss://relay.yozora.world", "wss://filter.nostr.wine/?global=all", "wss://eden.nostr.land",
|
"wss://yabu.me", "wss://relay.yozora.world", "wss://filter.nostr.wine/?global=all", "wss://eden.nostr.land",
|
||||||
"wss://relay.orangepill.ovh", "wss://nostr.jcloud.es", "wss://af.purplerelay.com", "wss://za.purplerelay.com",
|
"wss://relay.orangepill.ovh", "wss://nostr.jcloud.es", "wss://af.purplerelay.com", "wss://za.purplerelay.com",
|
||||||
"wss://relay.nostrich.land", "wss://relay.nostrplebs.com", "wss://relay.nostrich.land",
|
"wss://relay.nostrich.land", "wss://relay.nostrplebs.com", "wss://relay.nostrich.land",
|
||||||
@@ -416,7 +416,7 @@ def playground():
|
|||||||
|
|
||||||
options_top_zapped = {
|
options_top_zapped = {
|
||||||
"db_name": "db/nostr_recent_notes.db",
|
"db_name": "db/nostr_recent_notes.db",
|
||||||
"db_since": 60 * 60 * 8, # 8h since gmt,
|
"db_since": 60 * 60 * 6, # 8h since gmt,
|
||||||
}
|
}
|
||||||
cost = 0
|
cost = 0
|
||||||
image = "https://image.nostr.build/c6879f458252641d04d0aa65fd7f1e005a4f7362fd407467306edc2f4acdb113.jpg"
|
image = "https://image.nostr.build/c6879f458252641d04d0aa65fd7f1e005a4f7362fd407467306edc2f4acdb113.jpg"
|
||||||
|
|||||||
Reference in New Issue
Block a user