thread

package
v0.0.0-...-31fc120 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Raw              = 0x55
	AccessControlled = 0x70 // Supports access control lists
)

Variants.

View Source
const (
	V1 = 0x01
)

Versions.

Variables

View Source
var (
	// ErrVarintBuffSmall means that a buffer passed to the ID parser was not
	// long enough, or did not contain an invalid ID.
	ErrVarintBuffSmall = fmt.Errorf("reading varint: buffer too small")

	// ErrVarintTooBig means that the varint in the given ID was above the
	// limit of 2^64.
	ErrVarintTooBig = fmt.Errorf("reading varint: varint bigger than 64bits" +
		" and not supported")

	// ErrIDTooShort means that the ID passed to decode was not long
	// enough to be a valid ID.
	ErrIDTooShort = fmt.Errorf("id too short")
)
View Source
var Undef = ID{}

Undef can be used to represent a nil or undefined Cid, using Cid{} directly is also acceptable.

View Source
var VariantToStr = map[uint64]string{
	Raw:              "raw",
	AccessControlled: "access_controlled",
}

VariantToStr maps the numeric variant to its name.

View Source
var Variants = map[string]uint64{
	"raw":     Raw,
	"textile": AccessControlled,
}

Variants maps the name of a variant to its variant.

Functions

func ExtractEncoding

func ExtractEncoding(v string) (mbase.Encoding, error)

Extract the encoding from an ID. If Decode on the same string did not return an error neither will this function.

Types

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 Textile 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 ID

type ID struct {
	// contains filtered or unexported fields
}

ID represents a self-describing thread identifier. It is formed by a Version, a Variant, and a random number of a given length.

func Cast

func Cast(data []byte) (ID, error)

Cast takes an ID data slice, parses it and returns an ID. For IDV1, the data buffer is in the form:

<version><variant><random-number>

Please use decode when parsing a regular ID string, as Cast does not expect multibase-encoded data. Cast accepts the output of ID.Bytes().

func Decode

func Decode(v string) (ID, error)

Decode parses an ID-encoded string and returns an ID object. For IDV1, an ID-encoded string is primarily a multibase string:

<multibase-type-code><base-encoded-string>

The base-encoded string represents a:

<version><variant><random-number>

func NewIDV1

func NewIDV1(variant uint64, size uint8) ID

NewIDV1 returns a new random ID using the given variant.

func (ID) Bytes

func (i ID) Bytes() []byte

Bytes returns the byte representation of an ID. The output of bytes can be parsed back into an ID with Cast().

func (ID) Defined

func (i ID) Defined() bool

Defined returns true if an ID is defined. Calling any other methods on an undefined ID will result in undefined behavior.

func (ID) Encode

func (i ID) Encode(base mbase.Encoder) string

Encode return the string representation of an ID in a given base when applicable.

func (ID) Equals

func (i ID) Equals(o ID) bool

Equals checks that two IDs are the same.

func (ID) KeyString

func (i ID) KeyString() string

KeyString returns the binary representation of the ID as a string.

func (ID) Loggable

func (i ID) Loggable() map[string]interface{}

Loggable returns a Loggable (as defined by https://godoc.org/github.com/ipfs/go-log).

func (ID) MarshalBinary

func (i ID) MarshalBinary() ([]byte, error)

MarshalBinary is equivalent to Bytes(). It implements the encoding.BinaryMarshaler interface.

func (ID) MarshalText

func (i ID) MarshalText() ([]byte, error)

MarshalText is equivalent to String(). It implements the encoding.TextMarshaler interface.

func (ID) String

func (i ID) String() string

String returns the default string representation of an ID. Currently, Base32 is used as the encoding for the multibase string.

func (ID) StringOfBase

func (i ID) StringOfBase(base mbase.Encoding) (string, error)

String returns the string representation of an ID encoded is selected base.

func (*ID) UnmarshalBinary

func (i *ID) UnmarshalBinary(data []byte) error

UnmarshalBinary is equivalent to Cast(). It implements the encoding.BinaryUnmarshaler interface.

func (*ID) UnmarshalText

func (i *ID) UnmarshalText(text []byte) error

UnmarshalText is equivalent to Decode(). It implements the encoding.TextUnmarshaler interface.

func (ID) Variant

func (i ID) Variant() uint64

Variant returns the variant of an ID.

func (ID) Version

func (i ID) Version() uint64

Version returns the ID version.

type IDSlice

type IDSlice []ID

IDSlice for sorting threads.

func (IDSlice) Len

func (s IDSlice) Len() int

func (IDSlice) Less

func (s IDSlice) Less(i, j int) bool

func (IDSlice) Swap

func (s IDSlice) Swap(i, j int)

type Info

type Info struct {
	ID        ID
	Logs      peer.IDSlice
	FollowKey *sym.Key
	ReadKey   *sym.Key
}

Info holds a thread ID associated known logs.

type LogInfo

type LogInfo struct {
	ID      peer.ID
	PubKey  ic.PubKey
	PrivKey ic.PrivKey
	Addrs   []ma.Multiaddr
	Heads   []cid.Cid
}

LogInfo holds known info about a log.

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 ic.PubKey) error
}

Record is the most basic component of a log.

Jump to

Keyboard shortcuts

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