cbor

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cbor provides utilities to create or convert data to and from CBOR format (https://cbor.io/).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEvent added in v0.1.6

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 added in v0.1.6

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

func DecodeBlock(block blocks.Block, key crypto.DecryptionKey) (format.Node, error)

DecodeBlock returns a node by decrypting the block's raw bytes with key.

func EncodeBlock

func EncodeBlock(block blocks.Block, key crypto.EncryptionKey) (format.Node, error)

EncodeBlock returns a node by encrypting the block's raw bytes with key.

func GetEvent

func GetEvent(ctx context.Context, dag format.DAGService, id cid.Cid) (net.Event, error)

GetEvent returns the event node for the given cid.

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

func RecordFromNode(coded format.Node, key crypto.DecryptionKey) (net.Record, error)

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 added in v0.1.13

func RemoveEvent(ctx context.Context, dag format.DAGService, e *Event) error

RemoveEvent removes an event from the dag service.

func RemoveRecord added in v0.1.13

func RemoveRecord(ctx context.Context, dag format.DAGService, rec net.Record) error

RemoveRecord removes a record from the dag service.

Types

type CreateRecordConfig added in v0.1.13

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

type Event struct {
	format.Node
	// contains filtered or unexported fields
}

Event is a IPLD node representing an event.

func EventFromNode

func EventFromNode(node format.Node) (*Event, error)

EventFromNode decodes the given node into an event.

func EventFromRecord

func EventFromRecord(ctx context.Context, dag format.DAGService, rec net.Record) (*Event, error)

EventFromRecord returns the event within the given node.

func (*Event) BodyID

func (e *Event) BodyID() cid.Cid

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)

func (*Event) HeaderID

func (e *Event) HeaderID() cid.Cid

type EventHeader

type EventHeader struct {
	format.Node
	// contains filtered or unexported fields
}

EventHeader is an IPLD node representing an event header.

func (*EventHeader) Key

func (h *EventHeader) Key() (crypto.DecryptionKey, error)

type Record

type Record struct {
	format.Node
	// contains filtered or unexported fields
}

Record is an IPLD node representing a record.

func (*Record) BlockID

func (r *Record) BlockID() cid.Cid

func (*Record) GetBlock

func (r *Record) GetBlock(ctx context.Context, dag format.DAGService) (format.Node, error)

func (*Record) PrevID

func (r *Record) PrevID() cid.Cid

func (*Record) PubKey added in v0.1.13

func (r *Record) PubKey() []byte

func (*Record) Sig

func (r *Record) Sig() []byte

func (*Record) Verify

func (r *Record) Verify(key ic.PubKey) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL