check for self-zaps on top zap dvm

This commit is contained in:
Believethehype 2024-06-11 00:09:12 +02:00
parent e1aae85f53
commit 9def17c777
3 changed files with 17 additions and 11 deletions

View File

@ -133,12 +133,17 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
for event in events:
if event.created_at().as_secs() > timestamp_hour_ago:
filt = Filter().kinds([definitions.EventDefinitions.KIND_ZAP]).event(event.id()).since(since)
reactions = await database.query([filt])
zaps = await database.query([filt])
invoice_amount = 0
haspreimage = False
if len(reactions) >= self.min_reactions:
for reaction in reactions:
for tag in reaction.tags():
if len(zaps) >= self.min_reactions:
has_preimage = False
overall_amount = 0
for zap in zaps:
if event.author().to_hex() == zap.author().to_hex():
continue #Skip self zaps..
invoice_amount = 0
for tag in zap.tags():
# print(tag.as_vec())
if tag.as_vec()[0] == 'bolt11':
# print(tag.as_vec()[1])
@ -147,9 +152,10 @@ class DicoverContentCurrentlyPopularZaps(DVMTaskInterface):
if tag.as_vec()[0] == 'preimage':
if len(tag.as_vec()) > 1:
if tag.as_vec()[1] != "":
haspreimage = True # TODO further check preimage
if haspreimage:
ns.finallist[event.id().to_hex()] = invoice_amount
overall_amount += invoice_amount
has_preimage = True # TODO further check preimage
if has_preimage:
ns.finallist[event.id().to_hex()] = overall_amount
result_list = []

View File

@ -1,6 +1,6 @@
from setuptools import setup, find_packages
VERSION = '0.6.3'
VERSION = '0.6.4'
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information')

View File

@ -22,7 +22,7 @@ from nostr_dvm.utils.nip89_utils import create_amount_tag, NIP89Config, check_an
from nostr_dvm.utils.nostr_utils import check_and_set_private_key
from nostr_dvm.utils.zap_utils import check_and_set_ln_bits_keys
rebroadcast_NIP89 = True # Announce NIP89 on startup
rebroadcast_NIP89 = False # Announce NIP89 on startup
rebroadcast_NIP65_Relay_List = False
update_profile = False
@ -416,7 +416,7 @@ def playground():
options_top_zapped = {
"db_name": "db/nostr_recent_notes.db",
"db_since": 60 * 60 * 6, # 6h since gmt,
"db_since": 60 * 60 * 8, # 8h since gmt,
}
cost = 0
image = "https://image.nostr.build/c6879f458252641d04d0aa65fd7f1e005a4f7362fd407467306edc2f4acdb113.jpg"