log

package
v0.0.0-...-72dc9a7 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendOptions

type AppendOptions = iface.AppendOptions

type CanAppendContext

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

func (*CanAppendContext) GetLogEntries

func (c *CanAppendContext) GetLogEntries() []accesscontroller.LogEntry

type Entry

type Entry = iface.IPFSLogEntry

type FetchOptions

type FetchOptions struct {
	Length        *int
	Exclude       []iface.IPFSLogEntry
	ShouldExclude iface.ExcludeFunc
	ProgressChan  chan iface.IPFSLogEntry
	Timeout       time.Duration
	Concurrency   int
	SortFn        iface.EntrySortFn
}

type IO

type IO = iface.IO

type IPFSLog

type IPFSLog struct {
	Storage          core_iface.CoreAPI
	ID               string
	AccessController accesscontroller.Interface
	SortFn           iface.EntrySortFn
	Identity         *identityprovider.Identity
	Entries          iface.IPFSLogOrderedEntries

	Next  iface.IPFSLogOrderedEntries
	Clock iface.IPFSLogLamportClock
	// contains filtered or unexported fields
}

func NewFromEntry

func NewFromEntry(ctx context.Context, services core_iface.CoreAPI, identity *identityprovider.Identity, sourceEntries []iface.IPFSLogEntry, logOptions *LogOptions, fetchOptions *entry.FetchOptions) (*IPFSLog, error)

NewFromEntry Creates a IPFSLog from an Entry

Creating a log from an entry will retrieve entries from IPFS, thus causing side effects

func NewFromEntryHash

func NewFromEntryHash(ctx context.Context, services core_iface.CoreAPI, identity *identityprovider.Identity, hash cid.Cid, logOptions *LogOptions, fetchOptions *FetchOptions) (*IPFSLog, error)

NewFromEntryHash Creates a IPFSLog from a hash of an Entry

Creating a log from a hash will retrieve entries from IPFS, thus causing side effects

func NewFromJSON

func NewFromJSON(ctx context.Context, services core_iface.CoreAPI, identity *identityprovider.Identity, jsonLog *iface.JSONLog, logOptions *LogOptions, fetchOptions *entry.FetchOptions) (*IPFSLog, error)

NewFromJSON Creates a IPFSLog from a JSON Snapshot

Creating a log from a JSON Snapshot will retrieve entries from IPFS, thus causing side effects

func NewFromMultihash

func NewFromMultihash(ctx context.Context, services core_iface.CoreAPI, identity *identityprovider.Identity, hash cid.Cid, logOptions *LogOptions, fetchOptions *FetchOptions) (*IPFSLog, error)

NewFromMultihash Creates a IPFSLog from a hash

Creating a log from a hash will retrieve entries from IPFS, thus causing side effects

func NewLog

func NewLog(services core_iface.CoreAPI, identity *identityprovider.Identity, options *LogOptions) (*IPFSLog, error)

NewLog Creates creates a new IPFSLog for a given identity

Each IPFSLog gets a unique ID, which can be passed in the options as ID.

Returns a log instance.

ipfs is an instance of IPFS.

identity is an instance of Identity and will be used to sign entries Usually this should be a user id or similar.

options.AccessController is an instance of accesscontroller.Interface, which by default allows anyone to append to the IPFSLog.

func (*IPFSLog) Append

func (l *IPFSLog) Append(ctx context.Context, payload []byte, opts *AppendOptions) (iface.IPFSLogEntry, error)

Append Appends an entry to the log Returns the latest Entry

payload is the data that will be in the Entry

func (*IPFSLog) AppendByNewTime

func (l *IPFSLog) AppendByNewTime(ctx context.Context, payload []byte, opts *AppendOptions, newTime int) (iface.IPFSLogEntry, error)

Append Appends an entry to the log Returns the latest Entry it need to give clock time to the current entry payload is the data that will be in the Entry

func (*IPFSLog) Get

func (l *IPFSLog) Get(c cid.Cid) (Entry, bool)

func (*IPFSLog) GetEntries

func (l *IPFSLog) GetEntries() iface.IPFSLogOrderedEntries

func (*IPFSLog) GetID

func (l *IPFSLog) GetID() string

func (*IPFSLog) Has

func (l *IPFSLog) Has(c cid.Cid) bool

func (*IPFSLog) Heads

func (l *IPFSLog) Heads() iface.IPFSLogOrderedEntries

Heads Returns the heads of the log

Heads are the entries that are not referenced by other entries in the log

func (*IPFSLog) IO

func (l *IPFSLog) IO() IO

func (*IPFSLog) Iterator

func (l *IPFSLog) Iterator(options *IteratorOptions, output chan<- iface.IPFSLogEntry) error

Iterator Provides entries values on a channel

func (*IPFSLog) Join

func (l *IPFSLog) Join(otherLog iface.IPFSLog, size int) (iface.IPFSLog, error)

Join Joins the log with another log

Returns a log instance.

The size of the joined log can be specified by specifying the size argument, to include all values use -1

func (*IPFSLog) Len

func (l *IPFSLog) Len() int

func (*IPFSLog) RawHeads

func (l *IPFSLog) RawHeads() iface.IPFSLogOrderedEntries

func (*IPFSLog) SetIdentity

func (l *IPFSLog) SetIdentity(identity *identityprovider.Identity)

func (*IPFSLog) ToJSONLog

func (l *IPFSLog) ToJSONLog() *iface.JSONLog

ToJSON Returns a log in a JSON serializable structure

func (*IPFSLog) ToMultihash

func (l *IPFSLog) ToMultihash(ctx context.Context) (cid.Cid, error)

ToMultihash Returns the multihash of the log

Converting the log to a multihash will persist the contents of log.toJSON to IPFS, thus causing side effects

The supported format is defined by the log and a CIDv1 is returned

func (*IPFSLog) ToSnapshot

func (l *IPFSLog) ToSnapshot() *Snapshot

ToSnapshot exports a Snapshot-able version of the log

func (*IPFSLog) ToString

func (l *IPFSLog) ToString(payloadMapper func(iface.IPFSLogEntry) string) string

ToString Returns the log values as a nicely formatted string

payloadMapper is a function to customize text representation, use nil to use the default mapper which convert the payload as a string

func (*IPFSLog) Values

func (l *IPFSLog) Values() iface.IPFSLogOrderedEntries

Values Returns an Array of entries in the log

The values are in linearized order according to their Lamport clocks

type IteratorOptions

type IteratorOptions = iface.IteratorOptions

type JSONLog

type JSONLog = iface.JSONLog

type Log

type Log = iface.IPFSLog

type LogOptions

type LogOptions = iface.LogOptions

type Snapshot

type Snapshot = iface.Snapshot

type SortFn

type SortFn = iface.EntrySortFn

Jump to

Keyboard shortcuts

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