entry

package
v0.0.0-...-b1de795 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0, MIT Imports: 17 Imported by: 2

Documentation

Overview

Package entry defines the Entry structure for IPFS Log and its associated methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEntry

func CreateEntry(ctx context.Context, ipfsInstance core_iface.CoreAPI, identity *identityprovider.Identity, data *Entry, opts *iface.CreateEntryOptions) (iface.IPFSLogEntry, error)

func CreateEntryWithIO

func CreateEntryWithIO(ctx context.Context, ipfsInstance core_iface.CoreAPI, identity *identityprovider.Identity, data iface.IPFSLogEntry, opts *iface.CreateEntryOptions, io iface.IO) (iface.IPFSLogEntry, error)

CreateEntryWithIO creates an Entry.

func Difference

func Difference(a []iface.IPFSLogEntry, b []iface.IPFSLogEntry) []iface.IPFSLogEntry

Difference gets the list of values not present in both entries sets.

func FetchAll

func FetchAll(ctx context.Context, ipfs core_iface.CoreAPI, hashes []cid.Cid, options *FetchOptions) []iface.IPFSLogEntry

FetchAll gets entries from their CIDs.

func FetchParallel

func FetchParallel(ctx context.Context, ipfs core_iface.CoreAPI, hashes []cid.Cid, options *FetchOptions) []iface.IPFSLogEntry

FetchParallel has the same comportement than FetchAll, we keep it for retrop compatibility purpose

func FindChildren

func FindChildren(entry iface.IPFSLogEntry, values []iface.IPFSLogEntry) []iface.IPFSLogEntry

FindChildren finds an entry's children from an Array of entries.

Returns entry's children as an Array up to the last know child.

func FindHeads

func FindHeads(entries iface.IPFSLogOrderedEntries) []iface.IPFSLogEntry

FindHeads search entries heads in an OrderedMap.

func FromMultihash

func FromMultihash(ctx context.Context, ipfs core_iface.CoreAPI, hash cid.Cid, provider identityprovider.Interface) (iface.IPFSLogEntry, error)

FromMultihash creates an Entry from a hash.

func FromMultihashWithIO

func FromMultihashWithIO(ctx context.Context, ipfs core_iface.CoreAPI, hash cid.Cid, provider identityprovider.Interface, io iface.IO) (iface.IPFSLogEntry, error)

FromMultihashWithIO creates an Entry from a hash.

func NewOrderedMap

func NewOrderedMap() iface.IPFSLogOrderedEntries

NewOrderedMap creates a new OrderedMap of entries.

func NewOrderedMapFromEntries

func NewOrderedMapFromEntries(entries []iface.IPFSLogEntry) iface.IPFSLogOrderedEntries

NewOrderedMapFromEntries creates a new OrderedMap of entries from a slice.

func ToHashable

func ToHashable(e iface.IPFSLogEntry) (*iface.Hashable, error)

ToHashable Converts an entry to hashable.

func ToMultihashWithIO

func ToMultihashWithIO(ctx context.Context, e iface.IPFSLogEntry, ipfsInstance core_iface.CoreAPI, opts *iface.CreateEntryOptions, io iface.IO) (cid.Cid, error)

ToMultihashWithIO gets the multihash of an Entry.

Types

type Entry

type Entry struct {
	Payload        []byte                     `json:"payload,omitempty"`
	LogID          string                     `json:"id,omitempty"`
	Next           []cid.Cid                  `json:"next,omitempty"`
	Refs           []cid.Cid                  `json:"refs,omitempty"`
	V              uint64                     `json:"v,omitempty"`
	Key            []byte                     `json:"key,omitempty"`
	Sig            []byte                     `json:"sig,omitempty"`
	Identity       *identityprovider.Identity `json:"identity,omitempty"`
	Hash           cid.Cid                    `json:"hash,omitempty"`
	Clock          *LamportClock              `json:"clock,omitempty"`
	AdditionalData map[string]string          `json:"-"`
}

func Normalize

func Normalize(e iface.IPFSLogEntry, opts *normalizeEntryOpts) *Entry

func (*Entry) Copy

func (e *Entry) Copy() iface.IPFSLogEntry

Copy creates a copy of an entry.

func (*Entry) Defined

func (e *Entry) Defined() bool

func (*Entry) Equals

func (e *Entry) Equals(b iface.IPFSLogEntry) bool

Equals checks that two entries are identical.

func (*Entry) GetAdditionalData

func (e *Entry) GetAdditionalData() map[string]string

func (*Entry) GetClock

func (e *Entry) GetClock() iface.IPFSLogLamportClock

func (*Entry) GetHash

func (e *Entry) GetHash() cid.Cid

func (*Entry) GetIdentity

func (e *Entry) GetIdentity() *identityprovider.Identity

func (*Entry) GetKey

func (e *Entry) GetKey() []byte

func (*Entry) GetLogID

func (e *Entry) GetLogID() string

func (*Entry) GetNext

func (e *Entry) GetNext() []cid.Cid

func (*Entry) GetPayload

func (e *Entry) GetPayload() []byte

func (*Entry) GetRefs

func (e *Entry) GetRefs() []cid.Cid

func (*Entry) GetSig

func (e *Entry) GetSig() []byte

func (*Entry) GetV

func (e *Entry) GetV() uint64

func (*Entry) IsParent

func (e *Entry) IsParent(b iface.IPFSLogEntry) bool

func (*Entry) IsValid

func (e *Entry) IsValid() bool

isValid checks that an entry is valid.

func (*Entry) New

func (e *Entry) New() iface.IPFSLogEntry

func (*Entry) SetAdditionalDataValue

func (e *Entry) SetAdditionalDataValue(key string, value string)

func (*Entry) SetClock

func (e *Entry) SetClock(clock iface.IPFSLogLamportClock)

func (*Entry) SetHash

func (e *Entry) SetHash(hash cid.Cid)

func (*Entry) SetIdentity

func (e *Entry) SetIdentity(identity *identityprovider.Identity)

func (*Entry) SetKey

func (e *Entry) SetKey(key []byte)

func (*Entry) SetLogID

func (e *Entry) SetLogID(logID string)

func (*Entry) SetNext

func (e *Entry) SetNext(next []cid.Cid)

func (*Entry) SetPayload

func (e *Entry) SetPayload(payload []byte)

func (*Entry) SetRefs

func (e *Entry) SetRefs(refs []cid.Cid)

func (*Entry) SetSig

func (e *Entry) SetSig(sig []byte)

func (*Entry) SetV

func (e *Entry) SetV(v uint64)

func (*Entry) ToMultihash

func (e *Entry) ToMultihash(ctx context.Context, ipfsInstance core_iface.CoreAPI, opts *iface.CreateEntryOptions) (cid.Cid, error)

ToMultihash gets the multihash of an Entry.

func (*Entry) Verify

func (e *Entry) Verify(identity identityprovider.Interface, io iface.IO) error

Verify checks the entry's signature.

type FetchOptions

type FetchOptions = iface.FetchOptions

type Fetcher

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

func NewFetcher

func NewFetcher(ipfs core_iface.CoreAPI, options *FetchOptions) *Fetcher

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context, hashes []cid.Cid) []iface.IPFSLogEntry

type LamportClock

type LamportClock struct {
	ID   []byte `json:"id,omitempty"`
	Time int    `json:"time,omitempty"`
}

func CopyLamportClock

func CopyLamportClock(clock iface.IPFSLogLamportClock) *LamportClock

CopyLamportClock returns a copy of a lamport clock

func NewLamportClock

func NewLamportClock(identity []byte, time int) *LamportClock

NewLamportClock creates a new LamportClock instance.

func (*LamportClock) Compare

func (l *LamportClock) Compare(b iface.IPFSLogLamportClock) int

Compare calculate the "distance" based on the clock, ie. lower or greater.

func (*LamportClock) Defined

func (l *LamportClock) Defined() bool

func (*LamportClock) GetID

func (l *LamportClock) GetID() []byte

func (*LamportClock) GetTime

func (l *LamportClock) GetTime() int

func (*LamportClock) Merge

Merge fusion two LamportClocks.

func (*LamportClock) New

func (*LamportClock) SetID

func (l *LamportClock) SetID(i []byte)

func (*LamportClock) SetTime

func (l *LamportClock) SetTime(i int)

func (*LamportClock) Tick

Tick increments the time value, returns a new instance of LamportClock.

type OrderedMap

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

OrderedMap is an ordered map of entries.

func (*OrderedMap) At

func (o *OrderedMap) At(index uint) iface.IPFSLogEntry

At gets an item at the given index in the map, returns nil if not found.

func (*OrderedMap) Copy

func (*OrderedMap) Get

func (o *OrderedMap) Get(key string) (iface.IPFSLogEntry, bool)

Get retrieves an Entry using its key.

func (*OrderedMap) Keys

func (o *OrderedMap) Keys() []string

Keys retrieves the ordered list of keys in the map.

func (*OrderedMap) Len

func (o *OrderedMap) Len() int

Len gets the length of the map.

func (*OrderedMap) Merge

Merge will fusion two OrderedMap of entries.

func (*OrderedMap) Reverse

func (o *OrderedMap) Reverse() iface.IPFSLogOrderedEntries

func (*OrderedMap) Set

func (o *OrderedMap) Set(key string, value iface.IPFSLogEntry)

Set defines an Entry in the map for a given key.

func (*OrderedMap) Slice

func (o *OrderedMap) Slice() []iface.IPFSLogEntry

Slice returns an ordered slice of the values existing in the map.

func (*OrderedMap) UnsafeGet

func (o *OrderedMap) UnsafeGet(key string) iface.IPFSLogEntry

UnsafeGet retrieves an Entry using its key, returns nil if not found.

Directories

Path Synopsis
Package sorting includes utilities for ordering slices of Entries.
Package sorting includes utilities for ordering slices of Entries.

Jump to

Keyboard shortcuts

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