UNPKG

@requestnetwork/data-access

Version:
33 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PendingStore = void 0; /** * A simple in-memory store to share state between DataReader and DataWriter * Useful to retrieve a transaction that was just emitted but is not confirmed yet **/ class PendingStore { constructor() { this.pending = new Map(); } /** Gets a pending tx */ get(channelId) { return this.pending.get(channelId); } findByTopics(topics) { const results = []; for (const [channelId, pendingItem] of this.pending.entries()) { if (topics.find((topic) => pendingItem.topics.includes(topic))) { results.push(Object.assign({ channelId }, pendingItem)); } } return results; } add(channelId, pendingItem) { this.pending.set(channelId, pendingItem); } remove(channelId) { this.pending.delete(channelId); } } exports.PendingStore = PendingStore; //# sourceMappingURL=pending-store.js.map