import { UInt256 } from '@neo-one/client-common-esnext-esm'; import { AddChange, Block, ChangeSet, DeleteChange, Output, OutputKey, ReadAllStorage, ReadGetAllStorage, ReadMetadataStorage, ReadStorage } from '@neo-one/node-core-esnext-esm'; import { Observable } from 'rxjs'; declare type TrackedChange = { readonly type: 'add'; readonly addValue: AddValue; readonly value: Value; readonly subType: 'add' | 'update'; } | { readonly type: 'delete'; readonly key: Key; }; declare type GetFunc = (key: Key) => Promise; declare type TryGetFunc = (key: Key) => Promise; export interface TrackedChangeWithKey { readonly type: string; readonly key: string; readonly value: TrackedChange; } export declare type TrackedChangeSet = ReadonlyArray>; interface BaseReadStorageCacheOptions { readonly readStorage: () => ReadStorage; readonly name: string; readonly createAddChange: (value: AddValue) => AddChange; readonly createDeleteChange?: (key: Key) => DeleteChange; readonly onAdd?: (value: AddValue) => Promise; } export declare class BaseReadStorageCache { readonly get: GetFunc; readonly tryGet: TryGetFunc; readonly tryGetValue: TryGetFunc; readonly onAdd: ((value: AddValue) => Promise) | undefined; readonly name: string; readonly mutableValues: { [key: string]: TrackedChange; }; protected readonly readStorage: () => ReadStorage; protected readonly createAddChange: (value: AddValue) => AddChange; protected readonly createDeleteChange: ((key: Key) => DeleteChange) | undefined; constructor(options: BaseReadStorageCacheOptions); getChangeSet(): ChangeSet; getTrackedChangeSet(): TrackedChangeSet; tryGetTracked(_key: Key): TrackedChange | undefined; } interface ReadStorageCacheOptions extends BaseReadStorageCacheOptions { readonly getKeyString: (key: Key) => string; } declare class ReadStorageCache extends BaseReadStorageCache { readonly getKeyString: (key: Key) => string; constructor(options: ReadStorageCacheOptions); tryGetTracked(key: Key): TrackedChange | undefined; addTrackedChange(key: string, value: TrackedChange): void; } interface ReadAllStorageCacheOptions { readonly readAllStorage: () => ReadAllStorage; readonly name: string; readonly createAddChange: (value: Value) => AddChange; readonly createDeleteChange?: (key: Key) => DeleteChange; readonly onAdd?: (value: Value) => Promise; readonly getKeyString: (key: Key) => string; readonly getKeyFromValue: (value: Value) => Key; } declare class ReadAllStorageCache extends ReadStorageCache { readonly all$: Observable; protected readonly readAllStorage: () => ReadAllStorage; protected readonly getKeyFromValue: (value: Value) => Key; constructor(options: ReadAllStorageCacheOptions); } interface ReadGetAllStorageCacheOptions { readonly readGetAllStorage: () => ReadGetAllStorage; readonly name: string; readonly createAddChange: (value: Value) => AddChange; readonly createDeleteChange?: (key: Key) => DeleteChange; readonly onAdd?: (value: Value) => Promise; readonly getKeyString: (key: Key) => string; readonly getKeyFromValue: (value: Value) => Key; readonly matchesPartialKey: (value: Value, key: PartialKey) => boolean; } declare class ReadGetAllStorageCache extends ReadStorageCache { readonly getAll$: (key: PartialKey) => Observable; protected readonly readGetAllStorage: () => ReadGetAllStorage; protected readonly getKeyFromValue: (value: Value) => Key; protected readonly matchesPartialKey: (value: Value, key: PartialKey) => boolean; constructor(options: ReadGetAllStorageCacheOptions); } declare type AddFunc = (value: Value) => Promise; declare type UpdateFunc = (value: Value, update: Update) => Promise; declare type DeleteFunc = (key: Key) => Promise; interface ReadAddUpdateDeleteStorageCacheOptions extends ReadStorageCacheOptions { readonly update: (value: Value, update: Update) => Value; readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadAddUpdateDeleteStorageCache extends ReadStorageCache { readonly add: AddFunc; readonly update: UpdateFunc; readonly delete: DeleteFunc; constructor(options: ReadAddUpdateDeleteStorageCacheOptions); } interface ReadAddUpdateStorageCacheOptions extends ReadStorageCacheOptions { readonly update: (value: Value, update: Update) => Value; readonly getKeyFromValue: (value: Value) => Key; readonly allowDupes?: boolean; } export declare class ReadAddUpdateStorageCache extends ReadStorageCache { readonly add: AddFunc; readonly update: UpdateFunc; constructor(options: ReadAddUpdateStorageCacheOptions); } interface ReadAddDeleteStorageCacheOptions extends ReadStorageCacheOptions { readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadAddDeleteStorageCache extends ReadStorageCache { readonly add: AddFunc; readonly delete: DeleteFunc; constructor(options: ReadAddDeleteStorageCacheOptions); } interface ReadAddStorageCacheOptions extends ReadStorageCacheOptions { readonly getKeyFromValue: (value: Value) => Key; readonly allowDupes?: boolean; } export declare class ReadAddStorageCache extends ReadStorageCache { readonly add: AddFunc; constructor(options: ReadAddStorageCacheOptions); } interface ReadGetAllAddDeleteStorageCacheOptions extends ReadGetAllStorageCacheOptions { readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadGetAllAddDeleteStorageCache extends ReadGetAllStorageCache { readonly add: AddFunc; readonly delete: DeleteFunc; constructor(options: ReadGetAllAddDeleteStorageCacheOptions); } interface ReadGetAllAddUpdateDeleteStorageCacheOptions extends ReadGetAllStorageCacheOptions { readonly update: (value: Value, update: Update) => Value; readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadGetAllAddUpdateDeleteStorageCache extends ReadGetAllStorageCache { readonly add: AddFunc; readonly update: UpdateFunc; readonly delete: DeleteFunc; constructor(options: ReadGetAllAddUpdateDeleteStorageCacheOptions); } interface ReadGetAllAddStorageCacheOptions extends ReadGetAllStorageCacheOptions { readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadGetAllAddStorageCache extends ReadGetAllStorageCache { readonly add: AddFunc; constructor(options: ReadGetAllAddStorageCacheOptions); } interface ReadAllAddUpdateDeleteStorageCacheOptions extends ReadAllStorageCacheOptions { readonly update: (value: Value, update: Update) => Value; readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadAllAddUpdateDeleteStorageCache extends ReadAllStorageCache { readonly add: AddFunc; readonly update: UpdateFunc; readonly delete: DeleteFunc; constructor(options: ReadAllAddUpdateDeleteStorageCacheOptions); } interface ReadAllAddStorageCacheOptions extends ReadAllStorageCacheOptions { readonly getKeyFromValue: (value: Value) => Key; } export declare class ReadAllAddStorageCache extends ReadAllStorageCache { readonly add: AddFunc; constructor(options: ReadAllAddStorageCacheOptions); } interface BlockLikeKey { readonly hashOrIndex: Block['hash'] | Block['index']; } interface BlockLike { readonly hash: Block['hash']; readonly index: Block['index']; } interface BlockLikeStorageCacheOptions extends BaseReadStorageCacheOptions { } export declare class BlockLikeStorageCache extends BaseReadStorageCache { protected readonly mutableIndexValues: { [index: string]: TrackedChange; }; constructor(options: BlockLikeStorageCacheOptions); add(value: Value): Promise; tryGetTracked(key: BlockLikeKey): TrackedChange | undefined; addTrackedChange(key: string, value: TrackedChange): void; } interface OutputValue { readonly hash: UInt256; readonly index: number; readonly output: Output; } export declare class OutputStorageCache extends ReadStorageCache { readonly add: AddFunc; constructor(readStorage: () => ReadStorage); } declare type TrackedMetadataChange = { readonly type: 'add'; readonly addValue: AddValue; readonly value: Value; readonly subType: 'add' | 'update'; } | { readonly type: 'delete'; }; declare type GetMetadataFunc = (key?: undefined) => Promise; declare type TryGetMetadataFunc = (key?: undefined) => Promise; interface BaseReadMetadataStorageCacheOptions { readonly readStorage: () => ReadMetadataStorage; readonly name: string; readonly createAddChange: (value: AddValue) => AddChange; readonly createDeleteChange?: () => DeleteChange; readonly onAdd?: (value: AddValue) => Promise; } export declare class BaseReadMetadataStorageCache { readonly get: GetMetadataFunc; readonly tryGet: TryGetMetadataFunc; mutableValue: TrackedMetadataChange | undefined; readonly onAdd: ((value: AddValue) => Promise) | undefined; protected readonly readStorage: () => ReadMetadataStorage; protected readonly name: string; protected readonly createAddChange: (value: AddValue) => AddChange; protected readonly createDeleteChange: (() => DeleteChange) | undefined; constructor(options: BaseReadMetadataStorageCacheOptions); getChangeSet(): ChangeSet; getTrackedChangeSet(): TrackedChangeSet; tryGetTracked(): TrackedMetadataChange | undefined; addTrackedChange(_key: string, value: TrackedMetadataChange): void; } declare class ReadMetadataStorageCache extends BaseReadMetadataStorageCache { } interface ReadAddUpdateMetadataStorageCacheOptions extends BaseReadMetadataStorageCacheOptions { readonly update: (value: Value, update: Update) => Value; } export declare class ReadAddUpdateMetadataStorageCache extends ReadMetadataStorageCache { readonly add: AddFunc; readonly update: UpdateFunc; constructor(options: ReadAddUpdateMetadataStorageCacheOptions); } export {};