Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶ added in v0.1.6
type API interface {
io.Closer
// GetHostID returns the host's peer id.
GetHostID(ctx context.Context) (peer.ID, error)
// CreateThread with id.
CreateThread(ctx context.Context, id thread.ID, opts ...KeyOption) (thread.Info, error)
// AddThread from a multiaddress.
AddThread(ctx context.Context, addr ma.Multiaddr, opts ...KeyOption) (thread.Info, error)
// GetThread with id.
GetThread(ctx context.Context, id thread.ID) (thread.Info, error)
// PullThread for new records.
PullThread(ctx context.Context, id thread.ID) error
// DeleteThread with id.
DeleteThread(ctx context.Context, id thread.ID) error
// AddFollower to a thread.
AddFollower(ctx context.Context, id thread.ID, paddr ma.Multiaddr) (peer.ID, error)
// CreateRecord with body.
CreateRecord(ctx context.Context, id thread.ID, body format.Node) (ThreadRecord, error)
// AddRecord to the given log.
AddRecord(ctx context.Context, id thread.ID, lid peer.ID, rec Record) error
// GetRecord returns the record at cid.
GetRecord(ctx context.Context, id thread.ID, rid cid.Cid) (Record, error)
// Subscribe returns a read-only channel of records.
Subscribe(ctx context.Context, opts ...SubOption) (<-chan ThreadRecord, error)
}
API is the network interface for thread orchestration.
type Event ¶
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)
}
Event is the Block format used by threads
type EventHeader ¶
type EventHeader interface {
format.Node
// Time returns the wall-clock time at which this event was created.
Time() (*time.Time, error)
// Key returns a single-use decryption key for the event body.
Key() (crypto.DecryptionKey, error)
}
EventHeader is the format of the event's header object
type KeyOption ¶ added in v0.1.6
type KeyOption func(*KeyOptions)
KeyOption specifies encryption keys.
func LogKey ¶ added in v0.1.6
LogKey defines the public or private key used to write a log records. If this is just a public key, the service itself won't be able to create records. In other words, all records must pre-created and added with AddRecord. If no log key is provided, one will be created internally.
type KeyOptions ¶ added in v0.1.6
KeyOptions defines options for keys when creating / adding a thread.
type Record ¶
type Record interface {
format.Node
// BlockID returns the cid of the node block.
BlockID() cid.Cid
// GetBlock loads the node block.
GetBlock(context.Context, format.DAGService) (format.Node, error)
// PrevID returns the cid of the previous node.
PrevID() cid.Cid
// Sig returns the node signature.
Sig() []byte
// Verify returns a non-nil error if the node signature is valid.
Verify(pk crypto.PubKey) error
}
Record is the most basic component of a log.
type Service ¶
type Service interface {
API
// DAGService provides a DAG API to the network.
format.DAGService
// Host provides a network identity.
Host() host.Host
}
Service is the network interface for thread orchestration.
type SubOptions ¶
SubOptions defines options for a thread subscription.