The default owner when creating ot posting to a channel.
This also changes the default author of posted data.
If undefined, your main identity will be used.
Retrieve all channels registered at the channel registry
Optional
options: ChannelSelectionOptionsConverts the raw represantation to ObjectData
Create a new channel.
If the channel already exists, this call is a noop.
The id of the channel. See class description for more details on how ids and channels are handled.
Optional
owner: null | SHA256IdHash<Person>If the owner is not passed, then your own main identity is used. If the owner is NULL, then no owner is set. If a value is given, then the value will be used as an owner.
Get the "AppendSenderProfile" setting for the specified channel.
Get the "maxSize" setting for the specified channel.
Get the "RegisterSenderProfileAtLeute" setting for the specified channel.
This returns the list of matching channel infos based on ChannelSelectionOptions.
It usually returns the channel infos of the latest merged versions, not the latest version in the version maps. Only if the ChannelSelectionOptions reference a specific version this version is returned instead of the latest merged one.
Optional
options: ChannelSelectionOptionsObtain a specific object from a channel.
id of the object to extract
Obtain a specific object from a channel.
This is a very inefficient implementation, because it iterates over the chain. In the future it would be better to just pick the object with the passed hash. But this only works when we have working reverse maps for getting the metadata. The other option would be to use the hash of the indexed metadata as id, then we don't have the reverse map problem.
id of the object to extract
Type of objects to retrieve. If type does not match an error is thrown.
Get all data from one or multiple channels.
Note the behavior when using ascending ordering (default) and count. It will return the 'count' latest elements in ascending order, not the 'count' oldest elements. It is counter intuitive and should either be fixed or the iterator interface should be the mandatory
Optional
queryOptions: QueryOptionsGet all data from a channel.
Type of objects to retrieve. If type does not match the object is skipped.
Optional
queryOptions: QueryOptionsIterate over all objects in the channels matching the query options.
Note that the sort order is not supported. It is silently ignored. Items are always returned in descending order regarding time. It is a single linked list underneath, so no way of efficiently iterating in the other direction.
Optional
queryOptions: QueryOptionsIterate over all objects in the channels matching the query options.
This method also returns only the objects of a certain type.
The type of the elements to iterate
Optional
queryOptions: QueryOptionsPost a new object to a channel.
The id of the channel to post to
The object to post to the channel
Optional
channelOwner: null | SHA256IdHash<Person>If the owner is not passed, then your own main identity is used. If the owner is NULL, then no owner is set. If a value is given, then the value will be used as an owner.
Optional
timestamp: numberOptional
author: SHA256IdHash<Person>Post a new object to a channel but only if it was not already posted to the channel
Note: This will iterate over the whole tree if the object does not exist, so it might be slow.
The id of the channel to post to
The object to post to the channel
Optional
channelOwner: null | SHA256IdHash<Person>If the owner it's not passed, then the this.defaultOwner is set. If the owner it's NULL, then no owner is set. If a value is given, then the value will be used as an owner.
Enable appending the default profile of the sender to each channel entry.
Default is disabled
Optional
enable: booleanIf size is specified, then restrict the size of a channel to this amount.
Excess data is deleted by the merge algorithms.
Optional
maxSize: numberEnable registering as metadata attached profiles with leute.
Default is disabled
Optional
enable: booleanStatic
differencesFind the differences in the chain starting from the common history
Note: this only works when both channel infos are from the same channel.
Static
mergeIterate multiple iterators by returning always the most current element of all of them.
It is assumed, that the iterators will return the elements sorted from highest to lowest value.
Example:
If you have multiple iterators (iter1, iter2, iter3) that would return these items:
Then this iterator implementation would return the items with these creation times: 9, 8, 7, 6, 5, 4, 3, 2, 1
When two or more iterators reach the same history, then the first iterator in the iterator list will continue iterating. The other iterators will stop. This is relevant if one iterator is faster than the other (because one iterator iterates over cached values instead of one objects -> e.g. an element cache in ui elements.)
If true, then stop iteration when all but one iterator reached their end. The first element of the last iterator is still returned, but then iteration stops. This is very useful for merging algorithms, because they can use the last item as common history for merging. Because this iteration also removes redundant iterators (that iterate over the same history) it will stop when multiple iterators iterate the same history.
If true (default) the common history element will be yielded as last element
If true (default false) only elements that are only in a single channel are yielded.
the RawChannelEntry, iterIndex (the index of the iterator in the iterators array that yielded this RawChannelEntry), activeIteratorCount (number of iterators that were active when this element was yielded)
Static
singleThis iterator just iterates the data elements of the passed channel.
Note: If you want to start iterating from a specific point in the chain and not from the start, you can just construct your own ChannelInfo object and set the head to the ChannelEntry where you want to start iterating.
iterate this channel
Optional
from: DateOptional
to: DateOptional
ids: string[]Optional
loadAuthor: boolean
This model manages distributed lists of data in so called 'channels'.
A channel is a list of objects stored as merkle-tree indexed by time. The list is sorted by creation time so that it can be distributed and merged.
Each channel is identified by a channelId (just a string) and the owner. In a distributed network only the owner can create channels. TODO: explain more about access rights and distribution and everything!
The structure is as follows: TODO: add PlantUml graph here
NOTE: This class manages one global one object called ChannelRegistry It therefore does not make sense to have multiple ChannelManager objects. We don't use a singleton, because it makes it harder to track where channels are used.