-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
35 lines (26 loc) · 949 Bytes
/
event.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
package net
import (
"context"
"github.com/dcnetio/gothreads-lib/crypto"
"github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format"
)
// Event is the Block format used by threads
type Event interface {
format.Node
// HeaderID returns the cid of the event header.
HeaderID() cid.Cid
// GetHeader loads and optionally decrypts the event header.
// If no key is given, the header time and key methods will return an error.
GetHeader(context.Context, format.DAGService, crypto.DecryptionKey) (EventHeader, error)
// BodyID returns the cid of the event body.
BodyID() cid.Cid
// GetBody loads and optionally decrypts the event body.
GetBody(context.Context, format.DAGService, crypto.DecryptionKey) (format.Node, error)
}
// EventHeader is the format of the event's header object
type EventHeader interface {
format.Node
// Key returns a single-use decryption key for the event body.
Key() (crypto.DecryptionKey, error)
}