rename "parameterized replaceable" to "addressable".
This commit is contained in:
parent
548abb5d4a
commit
fcf10541c8
|
@ -1,5 +1,5 @@
|
|||
import { Event } from './core.ts'
|
||||
import { isParameterizedReplaceableKind, isReplaceableKind } from './kinds.ts'
|
||||
import { isAddressableKind, isReplaceableKind } from './kinds.ts'
|
||||
|
||||
export type Filter = {
|
||||
ids?: string[]
|
||||
|
@ -98,7 +98,7 @@ export function getFilterLimit(filter: Filter): number {
|
|||
: Infinity,
|
||||
|
||||
// Parameterized replaceable events are limited by the number of authors, kinds, and "d" tags.
|
||||
filter.authors?.length && filter.kinds?.every(kind => isParameterizedReplaceableKind(kind)) && filter['#d']?.length
|
||||
filter.authors?.length && filter.kinds?.every(kind => isAddressableKind(kind)) && filter['#d']?.length
|
||||
? filter.authors.length * filter.kinds.length * filter['#d'].length
|
||||
: Infinity,
|
||||
)
|
||||
|
|
9
kinds.ts
9
kinds.ts
|
@ -15,11 +15,14 @@ export function isEphemeralKind(kind: number): boolean {
|
|||
return 20000 <= kind && kind < 30000
|
||||
}
|
||||
|
||||
/** Events are **parameterized replaceable**, which means that, for each combination of `pubkey`, `kind` and the `d` tag, only the latest event is expected to be stored by relays, older versions are expected to be discarded. */
|
||||
export function isParameterizedReplaceableKind(kind: number): boolean {
|
||||
/** Events are **addressable**, which means that, for each combination of `pubkey`, `kind` and the `d` tag, only the latest event is expected to be stored by relays, older versions are expected to be discarded. */
|
||||
export function isAddressableKind(kind: number): boolean {
|
||||
return 30000 <= kind && kind < 40000
|
||||
}
|
||||
|
||||
/** @deprecated use isAddressableKind instead */
|
||||
export const isParameterizedReplaceableKind = isAddressableKind
|
||||
|
||||
/** Classification of the event kind. */
|
||||
export type KindClassification = 'regular' | 'replaceable' | 'ephemeral' | 'parameterized' | 'unknown'
|
||||
|
||||
|
@ -28,7 +31,7 @@ export function classifyKind(kind: number): KindClassification {
|
|||
if (isRegularKind(kind)) return 'regular'
|
||||
if (isReplaceableKind(kind)) return 'replaceable'
|
||||
if (isEphemeralKind(kind)) return 'ephemeral'
|
||||
if (isParameterizedReplaceableKind(kind)) return 'parameterized'
|
||||
if (isAddressableKind(kind)) return 'parameterized'
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue