Skip adding ephemeral and dvm kinds to repository

This commit is contained in:
Jon Staab
2024-10-31 13:59:05 -07:00
parent c93d102c08
commit 5038046608
5 changed files with 13 additions and 4 deletions
+3 -1
View File
@@ -1,7 +1,7 @@
import {partition} from "@welshman/lib"
import {defaultOptimizeSubscriptions, getDefaultNetContext as originalGetDefaultNetContext} from "@welshman/net"
import type {Subscription, RelaysAndFilters, NetContext} from "@welshman/net"
import {WRAP, unionFilters} from "@welshman/util"
import {WRAP, isEphemeralKind, isDVMKind, unionFilters} from "@welshman/util"
import type {TrustedEvent, StampedEvent} from "@welshman/util"
import {tracker, repository} from './core'
import {makeRouter, getFilterSelections} from './router'
@@ -22,6 +22,8 @@ export const getDefaultNetContext = (overrides: Partial<NetContext> = {}) => ({
...originalGetDefaultNetContext(),
signEvent: (event: StampedEvent) => signer.get()?.sign(event),
onEvent: (url: string, event: TrustedEvent) => {
if (isEphemeralKind(event.kind) || isDVMKind(event.kind)) return
tracker.track(event.id, url)
repository.publish(event)
+1 -1
View File
@@ -139,7 +139,7 @@ export const optimizeSubscriptions = (subs: Subscription[]) => {
const closedSubs = new Set<string>()
const eosedSubs = new Set<string>()
const sentSubs = new Set<string>()
const mergedSubs = []
const mergedSubs: Subscription[] = []
for (const {relays, filters} of ctx.net.optimizeSubscriptions(group)) {
const mergedSub = makeSubscription({
+2
View File
@@ -1,4 +1,5 @@
import {kinds} from 'nostr-tools'
import {between} from '@welshman/lib'
export const isRegularKind = kinds.isRegularKind
export const isEphemeralKind = kinds.isEphemeralKind
@@ -6,6 +7,7 @@ export const isPlainReplaceableKind = kinds.isReplaceableKind
export const isParameterizedReplaceableKind = kinds.isParameterizedReplaceableKind
export const isReplaceableKind = (kind: number) =>
isPlainReplaceableKind(kind) || isParameterizedReplaceableKind(kind)
export const isDVMKind = (kind: number) => between([4999, 7001], kind)
export const PROFILE = 0
export const NOTE = 1
+2
View File
@@ -13,6 +13,7 @@ export const BOGUS_RELAY_URL = "bogus://welshman.relay"
export type RelayProfile = {
url: string
icon?: string
banner?: string
name?: string
pubkey?: string
contact?: string
@@ -21,6 +22,7 @@ export type RelayProfile = {
description?: string
supported_nips?: number[]
limitation?: {
min_pow_difficulty?: number
payment_required?: boolean
auth_required?: boolean
}
+5 -2
View File
@@ -1,6 +1,6 @@
import type {OmitStatics} from '@welshman/lib'
import {Fluent, uniqBy, mapVals, nth, nthEq, ensurePlural} from '@welshman/lib'
import {isRelayUrl, normalizeRelayUrl} from './Relay'
import {Fluent, uniq, uniqBy, mapVals, nth, nthEq, ensurePlural} from '@welshman/lib'
import {isRelayUrl, isShareableRelayUrl, normalizeRelayUrl} from './Relay'
import {Address, isContextAddress} from './Address'
import {GROUP, COMMUNITY} from './Kinds'
@@ -262,4 +262,7 @@ export const getAncestorTags = (tags: string[][]) => {
export const getAncestorTagValues = (tags: string[][]) =>
mapVals(tags => tags.map(nth(1)), getAncestorTags(tags))
export const getRelayHints = (tags: string[][]) =>
uniq(tags.flatMap(t => t.slice(2).filter(isShareableRelayUrl)))
export const uniqTags = (tags: string[][]) => uniqBy(t => t.join(":"), tags)