Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( IDs = B("ids") Kinds = B("kinds") Authors = B("authors") Since = B("since") Until = B("until") Limit = B("limit") Search = B("search") )
Functions ¶
Types ¶
type T ¶
type T struct { IDs *tag.T `json:"ids,omitempty"` Kinds *kinds.T `json:"kinds,omitempty"` Authors *tag.T `json:"authors,omitempty"` Tags *tags.T `json:"-,omitempty"` Since *timestamp.T `json:"since,omitempty"` Until *timestamp.T `json:"until,omitempty"` Search B `json:"search,omitempty"` Limit int `json:"limit,omitempty"` }
T is the primary query form for requesting events from a nostr relay.
The ordering of fields of filters is not specified as in the protocol there is no requirement to generate a hash for fast recognition of identical filters. However, for internal use in a relay, by applying a consistent sort order, this library will produce an identical JSON from the same *set* of fields no matter what order they were provided.
This is to facilitate the deduplication of filters so an effective identical match is not performed on an identical filter.
func (*T) Clone ¶
Clone creates a new filter with all the same elements in them, because they are immutable, basically, except setting the Limit field as 1, because it is used in the subscription management code to act as a reference counter, and making a clone implicitly means 1 reference.
func (*T) Fingerprint ¶
Fingerprint returns an 8 byte truncated sha256 hash of the filter in the canonical form created by MarshalJSON.
This hash is generated via the JSON encoded form of the filter, with the Limit field removed. This value should be set to zero after all results from a query of stored events, as per NIP-01.
func (*T) MarshalJSON ¶
func (*T) Sort ¶ added in v0.1.6
func (f *T) Sort()
Sort the fields of a filter so a fingerprint on a filter that has the same set of content produces the same fingerprint.