Re-work publishing of wrapped events

This commit is contained in:
Jon Staab
2025-10-17 11:33:22 -07:00
parent 543dbda64f
commit ca38cbe20b
11 changed files with 141 additions and 116 deletions
+5 -5
View File
@@ -34,7 +34,7 @@ export type RepositoryUpdate = {
removed: Set<string>
}
export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
export class Repository<E extends TrustedEvent = TrustedEvent> extends Emitter {
eventsById = new Map<string, E>()
eventsByWrap = new Map<string, E>()
eventsByAddress = new Map<string, E>()
@@ -133,8 +133,8 @@ export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
if (event) {
this.eventsById.delete(event.id)
if (isUnwrappedEvent(event)) {
this.eventsByWrap.delete(event.wrap.id)
for (const wrap of event.wraps || []) {
this.eventsByWrap.delete(wrap.id)
}
this.eventsByAddress.delete(getAddress(event))
@@ -235,8 +235,8 @@ export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
}
// Save wrapper index
if (isUnwrappedEvent(event)) {
this.eventsByWrap.set(event.wrap.id, event)
for (const wrap of event.wraps || []) {
this.eventsByWrap.set(wrap.id, event)
}
// Update our timestamp and author indexes