Documentation ¶
Overview ¶
Package ipfslog implements an append-only log CRDT on IPFS
Index ¶
- type AppendOptions
- type CanAppendContext
- type Entry
- type FetchOptions
- type IPFSLog
- func NewFromEntry(ctx context.Context, services core_iface.CoreAPI, ...) (*IPFSLog, error)
- func NewFromEntryHash(ctx context.Context, services core_iface.CoreAPI, ...) (*IPFSLog, error)
- func NewFromJSON(ctx context.Context, services core_iface.CoreAPI, ...) (*IPFSLog, error)
- func NewFromMultihash(ctx context.Context, services core_iface.CoreAPI, ...) (*IPFSLog, error)
- func NewLog(services core_iface.CoreAPI, identity *identityprovider.Identity, ...) (*IPFSLog, error)
- func (l *IPFSLog) Append(ctx context.Context, payload []byte, opts *AppendOptions) (iface.IPFSLogEntry, error)
- func (l *IPFSLog) Get(c cid.Cid) (Entry, bool)
- func (l *IPFSLog) GetClock() iface.IPFSLogLamportClock
- func (l *IPFSLog) GetEntries() iface.IPFSLogOrderedEntries
- func (l *IPFSLog) GetID() string
- func (l *IPFSLog) Has(c cid.Cid) bool
- func (l *IPFSLog) Heads() iface.IPFSLogOrderedEntries
- func (l *IPFSLog) Iterator(options *IteratorOptions, output chan<- iface.IPFSLogEntry) error
- func (l *IPFSLog) Join(otherLog iface.IPFSLog, size int) (iface.IPFSLog, error)
- func (l *IPFSLog) RawHeads() iface.IPFSLogOrderedEntries
- func (l *IPFSLog) SetEntries(entries iface.IPFSLogOrderedEntries)
- func (l *IPFSLog) SetIdentity(identity *identityprovider.Identity)
- func (l *IPFSLog) ToJSON() *JSONLog
- func (l *IPFSLog) ToMultihash(ctx context.Context) (cid.Cid, error)
- func (l *IPFSLog) ToSnapshot() *Snapshot
- func (l *IPFSLog) ToString(payloadMapper func(iface.IPFSLogEntry) string) string
- func (l *IPFSLog) Values() iface.IPFSLogOrderedEntries
- type IteratorOptions
- type JSONLog
- type Log
- type LogOptions
- type Snapshot
- type SortFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppendOptions ¶ added in v1.1.0
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 ProgressChan chan iface.IPFSLogEntry Timeout time.Duration Concurrency int SortFn iface.EntrySortFn }
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 *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) GetClock ¶
func (l *IPFSLog) GetClock() iface.IPFSLogLamportClock
func (*IPFSLog) GetEntries ¶
func (l *IPFSLog) GetEntries() iface.IPFSLogOrderedEntries
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) Iterator ¶
func (l *IPFSLog) Iterator(options *IteratorOptions, output chan<- iface.IPFSLogEntry) error
Iterator Provides entries values on a channel
func (*IPFSLog) Join ¶
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) RawHeads ¶
func (l *IPFSLog) RawHeads() iface.IPFSLogOrderedEntries
func (*IPFSLog) SetEntries ¶
func (l *IPFSLog) SetEntries(entries iface.IPFSLogOrderedEntries)
func (*IPFSLog) SetIdentity ¶ added in v1.1.0
func (l *IPFSLog) SetIdentity(identity *identityprovider.Identity)
func (*IPFSLog) ToMultihash ¶
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 only supported format is dag-cbor and a CIDv1 is returned
func (*IPFSLog) ToSnapshot ¶
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 LogOptions ¶
type LogOptions = iface.LogOptions
type SortFn ¶ added in v1.1.0
type SortFn = iface.EntrySortFn
Directories ¶
Path | Synopsis |
---|---|
Package accesscontroller defines a default access controller for IPFS Log, it won't actually check anything.
|
Package accesscontroller defines a default access controller for IPFS Log, it won't actually check anything. |
Package entry defines the Entry structure for IPFS Log and its associated methods.
|
Package entry defines the Entry structure for IPFS Log and its associated methods. |
sorting
Package sorting includes utilities for ordering slices of Entries.
|
Package sorting includes utilities for ordering slices of Entries. |
Package errmsg defines error messages used by the Go version of IPFS Log.
|
Package errmsg defines error messages used by the Go version of IPFS Log. |
example
module
|
|
Package identityprovider defines a default identity provider for IPFS Log and OrbitDB.
|
Package identityprovider defines a default identity provider for IPFS Log and OrbitDB. |
Package io defines helpers used within IPFS Log and OrbitDB.
|
Package io defines helpers used within IPFS Log and OrbitDB. |
Package keystore defines a local key manager for OrbitDB and IPFS Log.
|
Package keystore defines a local key manager for OrbitDB and IPFS Log. |