update tutorials with framework

This commit is contained in:
dbth 2025-01-02 12:11:23 +01:00
parent 6ceeec556d
commit 20ae96335a
5 changed files with 40 additions and 6 deletions

View File

@ -11,6 +11,7 @@ from pathlib import Path
import dotenv
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_sdk import Kind, Keys
from nostr_dvm.utils.admin_utils import AdminConfig
@ -20,6 +21,10 @@ from nostr_dvm.utils.zap_utils import change_ln_address
def run_dvm(identifier):
# Initialize the framework
framework = DVMFramework()
# This function will either create or load the parameters of our DVMConfig.
# Make sure you replace the identifier down in the main function with the one you generated in tutorial 2, or we will create a new one here.
dvm_config = build_default_config(identifier)
@ -60,8 +65,11 @@ def run_dvm(identifier):
return result
dvm.process = process # now we simply overwrite our DVM's process function with the one we defined here.
# and finally we run the DVM #RunDVM
dvm.run()
# we add each DVM to the framework, in this case the one we just built
framework.add(dvm)
# and finally we run the framework #RunDVM
framework.run()
# When the DVM is running you should see a blue message with the name and the public key in bech32 and hex format.
# For the next exercise, copy the Hex key, and let this DVM run, you will need it :)

View File

@ -10,6 +10,8 @@ import os
from pathlib import Path
import dotenv
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_sdk import Kind, Keys
from nostr_dvm.utils.admin_utils import AdminConfig
@ -19,6 +21,10 @@ from nostr_dvm.utils.zap_utils import change_ln_address
# We keep the main code structure almost the same as in tutorial02.
def run_dvm(identifier, announce):
# Initialize the framework
framework = DVMFramework()
dvm_config = build_default_config(identifier)
kind = Kind(5050)
dvm_config.KIND = kind
@ -93,7 +99,9 @@ def run_dvm(identifier, announce):
return result
dvm.process = process
dvm.run()
framework.add(dvm)
framework.run()

View File

@ -8,6 +8,8 @@ import os
from pathlib import Path
import dotenv
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_sdk import Kind, Keys
from nostr_dvm.utils.admin_utils import AdminConfig
@ -19,6 +21,9 @@ from nostr_dvm.utils.zap_utils import change_ln_address
# We keep the main code structure almost the same as in tutorial02 and 05.
def run_dvm(identifier, announce):
# Initialize the framework
framework = DVMFramework()
# Remember, with build_default_config(identifier) the framework will either create or load certain information
# such as private nostr keys, wallet information, and d tags.
dvm_config = build_default_config(identifier)
@ -144,7 +149,9 @@ def run_dvm(identifier, announce):
return result
dvm.process = process
dvm.run()
framework.add(dvm)
framework.run()

View File

@ -7,6 +7,8 @@ import os
from pathlib import Path
import dotenv
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_sdk import Kind, Keys
from nostr_dvm.utils.admin_utils import AdminConfig
@ -18,6 +20,8 @@ from nostr_dvm.utils.zap_utils import change_ln_address
# We keep the main code structure almost the same as in tutorial02 and 05.
def run_dvm(identifier, announce):
# Initialize the framework
framework = DVMFramework()
dvm_config = build_default_config(identifier)
kind = Kind(5050)
@ -119,7 +123,9 @@ def run_dvm(identifier, announce):
return result
dvm.process = process
dvm.run()
framework.add(dvm)
framework.run()

View File

@ -14,6 +14,8 @@ import os
from pathlib import Path
import dotenv
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_sdk import Kind, Keys
from nostr_dvm.utils.admin_utils import AdminConfig
@ -25,6 +27,8 @@ from nostr_dvm.utils.zap_utils import change_ln_address
def run_dvm(identifier, announce):
# Initialize the framework
framework = DVMFramework()
dvm_config = build_default_config(identifier)
kind = Kind(5050)
@ -71,7 +75,8 @@ def run_dvm(identifier, announce):
return result
dvm.process = process
dvm.run(True)
framework.add(dvm)
framework.run()