@fairdatasociety/fdp-lokijs-adapter
Version:
fdp-storage LokiJS DB Adapter
47 lines (46 loc) • 2.68 kB
TypeScript
import { BatchId, Bee, Reference, Signer, Topic } from '@ethersphere/bee-js';
import type { SingleOwnerChunk } from '@ethersphere/bee-js/dist/src/chunk/soc';
import type { ChunkReference } from '@ethersphere/bee-js/dist/src/feed';
import type { EthAddress } from '@ethersphere/bee-js/dist/src/utils/eth';
import { SwarmFeedHandler } from './feed';
import { Bytes } from './utils';
export interface StreamingFeedChunk extends SingleOwnerChunk {
index: number;
reference: ChunkReference;
timestamp: number;
updatePeriod: number;
}
export declare type FaultTolerantStreamType = 'fault-tolerant-stream';
/** Interface for feed type classes */
export interface IStreamingFeed<Index> {
/** Feed type identifier */
readonly type: FaultTolerantStreamType;
/** initialised BeeJS instance */
readonly bee: Bee;
/** get Feed interface with read operations */
makeFeedR(topic: Topic | Uint8Array | string, owner: EthAddress | Uint8Array | string, ...options: any[]): SwarmStreamingFeedR;
/** get Feed interface with write and read operations */
makeFeedRW(topic: Topic | Uint8Array | string, signer: Signer | Uint8Array | string, options?: any): SwarmStreamingFeedRW;
/** Get Single Owner Chunk identifier */
getIdentifier(topic: Bytes<32>, index: Index): Bytes<32>;
}
/** Swarm Feed Read operations */
export interface SwarmStreamingFeedR extends SwarmFeedHandler {
getIndexForArbitraryTime(lookupTime: number, initialTime?: number, updatePeriod?: number): number;
getUpdate(initialTime: number, updatePeriod: number, lookupTime?: number): Promise<StreamingFeedChunk>;
getUpdates(initialTime: number, updatePeriod: number): Promise<StreamingFeedChunk[]>;
findLastUpdate(initialTime: number, updatePeriod: number): Promise<StreamingFeedChunk>;
getLastIndex(initialTime: number, updatePeriod: number): Promise<number>;
}
/** Swarm Feed Read and Write operations */
export interface SwarmStreamingFeedRW extends SwarmStreamingFeedR {
setLastUpdate(postageBatchId: string | BatchId, reference: Reference, initialTime: number, updatePeriod: number, lookupTime?: number): Promise<Reference>;
setUpdate(index: number, postageBatchId: string | BatchId, reference: Reference, initialTime: number, updatePeriod: number, lookupTime?: number): Promise<Reference>;
}
export declare function extractDataFromSocPayload(payload: Uint8Array): StreamingFeedChunk;
export declare function mapSocToFeed<Index = number>(socChunk: SingleOwnerChunk): StreamingFeedChunk;
export declare function assembleSocPayload(reference: ChunkReference, options: {
at: number;
updatePeriod: number;
index: number;
}): Uint8Array;