UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

51 lines 1.9 kB
import { GossipQueue, IndexedGossipQueueMinSizeOpts } from "./types.js"; /** * This implementation tries to get the most items with same key: * - index items by indexFn using a map * - store keys with at least minChunkSize * - on next, pick the last key with minChunkSize, pop up to maxChunkSize items * - on delete, pick the 1st key in the map and delete the 1st item in the list * Although it does not strictly follow LIFO, it tries to have that behavior: * - On delete, get the first key and the first item of respective list * - On next pick the last key with minChunksize * - if there is no key with minChunkSize, pop the last item of the last key * * This is a special gossip queue for beacon_attestation topic */ export declare class IndexedGossipQueueMinSize<T extends { indexed?: string; queueAddedMs?: number; }> implements GossipQueue<T> { private readonly opts; private _length; private indexedItems; private minChunkSizeKeys; private nextWaitTimeMs; private lastWaitTimeCheckedMs; constructor(opts: IndexedGossipQueueMinSizeOpts<T>); get length(): number; get keySize(): number; clear(): void; /** * Get age of each key in ms. */ getDataAgeMs(): number[]; /** * Add item to gossip queue. If queue is full, drop first item of first key. * Return number of items dropped */ add(item: T): number; /** * Try to get items of last key with minChunkSize first. * If not, pick the last key with MINIMUM_WAIT_TIME_MS old */ next(): T[] | null; getAll(): T[]; /** * `indexedItems` is already sorted by key, so we can just iterate through it * Search for the last key with >= MINIMUM_WAIT_TIME_MS old * Do not search again if we already searched recently */ private lastMinWaitKey; } //# sourceMappingURL=indexed.d.ts.map