Documentation ¶
Overview ¶
Package cbor provides utilities to create or convert data to and from CBOR format (https://cbor.io/).
Index ¶
- func CreateEvent(ctx context.Context, dag format.DAGService, body format.Node, ...) (net.Event, error)
- func CreateRecord(ctx context.Context, dag format.DAGService, config CreateRecordConfig) (net.Record, error)
- func DecodeBlock(block blocks.Block, key crypto.DecryptionKey) (format.Node, error)
- func EncodeBlock(block blocks.Block, key crypto.EncryptionKey) (format.Node, error)
- func GetEvent(ctx context.Context, dag format.DAGService, id cid.Cid) (net.Event, error)
- func GetRecord(ctx context.Context, dag format.DAGService, id cid.Cid, ...) (net.Record, error)
- func RecordFromNode(coded format.Node, key crypto.DecryptionKey) (net.Record, error)
- func RecordFromProto(rec *pb.Log_Record, key crypto.DecryptionKey) (net.Record, error)
- func RecordToProto(ctx context.Context, dag format.DAGService, rec net.Record) (*pb.Log_Record, error)
- func RemoveEvent(ctx context.Context, dag format.DAGService, e *Event) error
- func RemoveRecord(ctx context.Context, dag format.DAGService, rec net.Record) error
- type CreateRecordConfig
- type Event
- func (e *Event) BodyID() cid.Cid
- func (e *Event) GetBody(ctx context.Context, dag format.DAGService, key crypto.DecryptionKey) (format.Node, error)
- func (e *Event) GetHeader(ctx context.Context, dag format.DAGService, key crypto.DecryptionKey) (net.EventHeader, error)
- func (e *Event) HeaderID() cid.Cid
- type EventHeader
- type Record
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEvent ¶
func CreateEvent(ctx context.Context, dag format.DAGService, body format.Node, rkey crypto.EncryptionKey) (net.Event, error)
CreateEvent create a new event by wrapping the body node.
func CreateRecord ¶
func CreateRecord(ctx context.Context, dag format.DAGService, config CreateRecordConfig) (net.Record, error)
CreateRecord returns a new record from the given block and log private key.
func DecodeBlock ¶
DecodeBlock returns a node by decrypting the block's raw bytes with key.
func EncodeBlock ¶
EncodeBlock returns a node by encrypting the block's raw bytes with key.
func GetRecord ¶
func GetRecord(ctx context.Context, dag format.DAGService, id cid.Cid, key crypto.DecryptionKey) (net.Record, error)
GetRecord returns a record from the given cid.
func RecordFromNode ¶
RecordFromNode decodes a record from a node using the given key.
func RecordFromProto ¶
func RecordFromProto(rec *pb.Log_Record, key crypto.DecryptionKey) (net.Record, error)
RecordFromProto returns a node from a serialized version that contains link data.
func RecordToProto ¶
func RecordToProto(ctx context.Context, dag format.DAGService, rec net.Record) (*pb.Log_Record, error)
RecordToProto returns a proto version of a record for transport. Nodes are sent encrypted.
func RemoveEvent ¶
RemoveEvent removes an event from the dag service.
func RemoveRecord ¶
RemoveRecord removes a record from the dag service.
Types ¶
type CreateRecordConfig ¶
type CreateRecordConfig struct { Block format.Node Prev cid.Cid Key ic.PrivKey PubKey thread.PubKey ServiceKey crypto.EncryptionKey }
CreateRecordConfig wraps all the elements needed for creating a new record.
type Event ¶
Event is a IPLD node representing an event.
func EventFromNode ¶
EventFromNode decodes the given node into an event.
func EventFromRecord ¶
EventFromRecord returns the event within the given node.
func (*Event) GetBody ¶
func (e *Event) GetBody(ctx context.Context, dag format.DAGService, key crypto.DecryptionKey) (format.Node, error)
func (*Event) GetHeader ¶
func (e *Event) GetHeader(ctx context.Context, dag format.DAGService, key crypto.DecryptionKey) (net.EventHeader, error)
type EventHeader ¶
EventHeader is an IPLD node representing an event header.
func (*EventHeader) Key ¶
func (h *EventHeader) Key() (crypto.DecryptionKey, error)