Make repository.load sync, move migrate into adapters

This commit is contained in:
Jon Staab
2024-09-27 12:46:39 -07:00
parent f27a64250e
commit 1ef7c1c59f
3 changed files with 15 additions and 25 deletions
+2 -6
View File
@@ -1,4 +1,4 @@
import {flatten, Emitter, sortBy, inc, chunk, sleep, uniq, omit, now, range, identity} from '@welshman/lib'
import {flatten, Emitter, sortBy, inc, chunk, uniq, omit, now, range, identity} from '@welshman/lib'
import {DELETE} from './Kinds'
import {EPOCH, matchFilter} from './Filters'
import {isReplaceable, isUnwrappedEvent} from './Events'
@@ -31,7 +31,7 @@ export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
return Array.from(this.eventsById.values())
}
load = async (events: E[], chunkSize = 1000) => {
load = (events: E[], chunkSize = 1000) => {
this.clear()
const added = []
@@ -42,10 +42,6 @@ export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
added.push(event)
}
}
if (eventsChunk.length === chunkSize) {
await sleep(1)
}
}
const removed = new Set(this.deletes.keys())