-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdvm.go
37 lines (29 loc) · 1.2 KB
/
dvm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package godvm
import (
"context"
goNostr "github.com/nbd-wtf/go-nostr"
)
type Dvmer interface {
// PublicKeyHex return the public key of the DVM in hex format.
PublicKeyHex() string
// KindSupported returns the job request kind that the DVM can handle.
KindSupported() int
// Version returns a string that is used as a d-tag for NIP-89 publishing.
// Refer to NIP-89: https://github.com/nostr-protocol/nips/blob/protected-events-tag/89.md
Version() string
// Profile returns the profile information of the DVM. This is used to publish both kind-0 and NIP-89 application
// handler events.
Profile() *ProfileMetadata
// Sign signs the given event with the private key of the DVM.
Sign(e *goNostr.Event) error
// Run executes the DVM main logic. The input comes directly from the nostr job request event.
// The return value must be `true` if your DVM wants to proceed with the job, else return `false`.
// If your DVM proceeds with the job, use the provided channels to communicate back and forth with the library.
// See the examples/ directory for a better explanation with code.
Run(
ctx context.Context,
input *Nip90Input,
chanToDvm <-chan *JobUpdate,
chanToEngine chan<- *JobUpdate,
) bool
}