Version: v1.0.0 Latest Latest

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

Go to latest
Published: Dec 28, 2019 License: Apache-2.0, MIT Imports: 16 Imported by: 6



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



This section is empty.


This section is empty.


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 io.IpfsServices, hashes []cid.Cid, options *FetchOptions) []iface.IPFSLogEntry

FetchAll gets entries from their CIDs.

func FetchParallel

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

FetchParallel retrieves IPFS log entries.

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 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.


type CborEntry

type CborEntry struct {
	V        uint64
	LogID    string
	Key      string
	Sig      string
	Hash     interface{}
	Next     []cid.Cid
	Clock    *CborLamportClock
	Payload  string
	Identity *identityprovider.CborIdentity

CborEntry CBOR representable version of Entry

func (*CborEntry) ToEntry

func (c *CborEntry) ToEntry(provider identityprovider.Interface) (*Entry, error)

ToEntry returns a plain Entry from a CBOR serialized version

type CborLamportClock

type CborLamportClock = iface.CborLamportClock

type Entry

type Entry struct {
	Payload  []byte                     `json:"payload,omitempty"`
	LogID    string                     `json:"id,omitempty"`
	Next     []cid.Cid                  `json:"next,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"`

func CreateEntry

func CreateEntry(ctx context.Context, ipfsInstance io.IpfsServices, identity *identityprovider.Identity, data *Entry, clock iface.IPFSLogLamportClock) (*Entry, error)

CreateEntry creates an Entry.

func (*Entry) Equals

func (e *Entry) Equals(b *Entry) bool

Equals checks that two entries are identical.

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) 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) 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) SetSig

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

func (*Entry) SetV

func (e *Entry) SetV(v uint64)

func (*Entry) ToCborEntry

func (e *Entry) ToCborEntry() interface{}

ToCborEntry creates a CBOR serializable version of an entry

func (*Entry) ToMultihash

func (e *Entry) ToMultihash(ctx context.Context, ipfsInstance io.IpfsServices) (cid.Cid, error)

ToMultihash gets the multihash of an Entry.

func (*Entry) Verify

func (e *Entry) Verify(identity identityprovider.Interface) error

Verify checks the entry's signature.

type FetchOptions

type FetchOptions = iface.FetchOptions

type Hashable

type Hashable struct {
	Hash    interface{}
	ID      string
	Payload []byte
	Next    []string
	V       uint64
	Clock   iface.IPFSLogLamportClock
	Key     []byte

type LamportClock

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

func NewLamportClock

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

NewLamportClock creates a new LamportClock instance.

func ToLamportClock

func ToLamportClock(c *CborLamportClock) (*LamportClock, error)

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) GetID

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

func (*LamportClock) GetTime

func (l *LamportClock) GetTime() int

func (*LamportClock) Merge

Merge fusion two LamportClocks.

func (*LamportClock) Tick

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

func (*LamportClock) ToCborLamportClock

func (l *LamportClock) ToCborLamportClock() *iface.CborLamportClock

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

Copy creates a copy of an OrderedMap.

func (*OrderedMap) Delete

func (o *OrderedMap) Delete(key string)

Delete removes an Entry from the map for a given key.

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) 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) Sort

func (o *OrderedMap) Sort(lessFunc func(a *orderedmap.Pair, b *orderedmap.Pair) bool)

Sort orders the map using your sort func.

func (*OrderedMap) SortKeys

func (o *OrderedMap) SortKeys(sortFunc func(keys []string))

SortKeys orders the map keys using your sort func.

func (*OrderedMap) UnsafeGet

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

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


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