Documentation
¶
Index ¶
- func GetImmediateReply(evt *nostr.Event) *nostr.Tag
- func GetThreadRoot(evt *nostr.Event) *nostr.Tag
- func InputToEventPointer(input string) *nostr.EventPointer
- func InputToProfile(ctx context.Context, input string) *nostr.ProfilePointer
- func IsVirtualRelay(url string) bool
- func PerQueryLimitInBatch(totalFilterLimit int, numberOfQueries int) int
- type EventRef
- type EventResult
- type GenericList
- type GenericSets
- type ProfileMetadata
- type ProfileRef
- type Relay
- type RelayStream
- type RelayURL
- type System
- func (sys *System) Close()
- func (sys *System) FetchBlockedRelayList(ctx context.Context, pubkey string) GenericList[RelayURL]
- func (sys *System) FetchBookmarkList(ctx context.Context, pubkey string) GenericList[EventRef]
- func (sys *System) FetchFeedPage(ctx context.Context, pubkeys []string, kinds []int, until nostr.Timestamp, ...) ([]*nostr.Event, error)
- func (sys *System) FetchFollowList(ctx context.Context, pubkey string) GenericList[ProfileRef]
- func (sys *System) FetchFollowSets(ctx context.Context, pubkey string) GenericSets[ProfileRef]
- func (sys *System) FetchInboxRelays(ctx context.Context, pubkey string, n int) []string
- func (sys *System) FetchMuteList(ctx context.Context, pubkey string) GenericList[ProfileRef]
- func (sys *System) FetchOutboxRelays(ctx context.Context, pubkey string, n int) []string
- func (sys *System) FetchPinList(ctx context.Context, pubkey string) GenericList[EventRef]
- func (sys System) FetchProfileFromInput(ctx context.Context, nip19OrNip05Code string) (ProfileMetadata, error)
- func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey string) (pm ProfileMetadata)
- func (sys *System) FetchRelayList(ctx context.Context, pubkey string) GenericList[Relay]
- func (sys *System) FetchRelaySets(ctx context.Context, pubkey string) GenericSets[RelayURL]
- func (sys *System) FetchSearchRelayList(ctx context.Context, pubkey string) GenericList[RelayURL]
- func (sys *System) FetchSpecificEvent(ctx context.Context, pointer nostr.Pointer, withRelays bool) (event *nostr.Event, successRelays []string, err error)
- func (sys *System) FetchSpecificEventFromInput(ctx context.Context, input string, withRelays bool) (event *nostr.Event, successRelays []string, err error)
- func (sys *System) FetchTopicList(ctx context.Context, pubkey string) GenericList[Topic]
- func (sys *System) FetchTopicSets(ctx context.Context, pubkey string) GenericSets[Topic]
- func (sys *System) FetchWriteRelays(ctx context.Context, pubkey string, n int) []string
- func (sys *System) GetEventRelays(eventID string) ([]string, error)
- func (sys *System) SearchUsers(ctx context.Context, query string) []ProfileMetadata
- func (sys *System) StreamLiveFeed(ctx context.Context, pubkeys []string, kinds []int) (<-chan *nostr.Event, error)
- func (sys *System) TrackEventHints(ie nostr.RelayEvent)
- func (sys *System) TrackEventHintsAndRelays(ie nostr.RelayEvent)
- func (sys *System) TrackEventRelaysD(relay, id string)
- func (sys *System) TrackQueryAttempts(relay string, author string, kind int)
- type SystemModifier
- func WithFallbackRelays(list []string) SystemModifier
- func WithFollowListCache(cache cache.Cache32[GenericList[ProfileRef]]) SystemModifier
- func WithFollowListRelays(list []string) SystemModifier
- func WithHintsDB(hdb hints.HintsDB) SystemModifier
- func WithJustIDRelays(list []string) SystemModifier
- func WithKVStore(store kvstore.KVStore) SystemModifier
- func WithMetadataCache(cache cache.Cache32[ProfileMetadata]) SystemModifier
- func WithMetadataRelays(list []string) SystemModifier
- func WithNoteSearchRelays(list []string) SystemModifier
- func WithRelayListCache(cache cache.Cache32[GenericList[Relay]]) SystemModifier
- func WithRelayListRelays(list []string) SystemModifier
- func WithStore(store eventstore.Store) SystemModifier
- func WithUserSearchRelays(list []string) SystemModifier
- type TagItemWithValue
- type Topic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetImmediateReply ¶ added in v0.46.0
func GetImmediateReply(evt *nostr.Event) *nostr.Tag
func GetThreadRoot ¶ added in v0.46.0
func GetThreadRoot(evt *nostr.Event) *nostr.Tag
func InputToEventPointer ¶
func InputToEventPointer(input string) *nostr.EventPointer
InputToEventPointer turns any note/nevent/hex input into a EventPointer (or nil).
func InputToProfile ¶
InputToProfile turns any npub/nprofile/hex/nip05 input into a ProfilePointer (or nil).
func IsVirtualRelay ¶ added in v0.36.0
IsVirtualRelay returns true if the given normalized relay URL shouldn't be considered for outbox-model calculations.
func PerQueryLimitInBatch ¶ added in v0.46.0
PerQueryLimitInBatch tries to make an educated guess for the batch size given the total filter limit and the number of abstract queries we'll be conducting at the same time
Types ¶
type EventResult ¶ added in v0.36.0
type EventResult dataloader.Result[*nostr.Event]
type GenericList ¶ added in v0.36.0
type GenericList[I TagItemWithValue] struct { PubKey string `json:"-"` // must always be set otherwise things will break Event *nostr.Event `json:"-"` // may be empty if a contact list event wasn't found Items []I }
type GenericSets ¶ added in v0.46.0
type GenericSets[I TagItemWithValue] struct { PubKey string `json:"-"` Events []*nostr.Event `json:"-"` Sets map[string][]I }
type ProfileMetadata ¶ added in v0.36.0
type ProfileMetadata struct { PubKey string `json:"-"` // must always be set otherwise things will break Event *nostr.Event `json:"-"` // may be empty if a profile metadata event wasn't found // every one of these may be empty Name string `json:"name,omitempty"` DisplayName string `json:"display_name,omitempty"` About string `json:"about,omitempty"` Website string `json:"website,omitempty"` Picture string `json:"picture,omitempty"` Banner string `json:"banner,omitempty"` NIP05 string `json:"nip05,omitempty"` LUD16 string `json:"lud16,omitempty"` // contains filtered or unexported fields }
func ParseMetadata ¶ added in v0.36.0
func ParseMetadata(event *nostr.Event) (meta ProfileMetadata, err error)
func (*ProfileMetadata) NIP05Valid ¶ added in v0.42.3
func (p *ProfileMetadata) NIP05Valid(ctx context.Context) bool
func (ProfileMetadata) Npub ¶ added in v0.36.0
func (p ProfileMetadata) Npub() string
func (ProfileMetadata) NpubShort ¶ added in v0.36.0
func (p ProfileMetadata) NpubShort() string
func (ProfileMetadata) ShortName ¶ added in v0.36.0
func (p ProfileMetadata) ShortName() string
type ProfileRef ¶ added in v0.46.0
func (ProfileRef) Value ¶ added in v0.46.0
func (f ProfileRef) Value() string
type RelayStream ¶ added in v0.38.2
type RelayStream struct { URLs []string // contains filtered or unexported fields }
func NewRelayStream ¶ added in v0.38.2
func NewRelayStream(urls ...string) *RelayStream
func (*RelayStream) Next ¶ added in v0.38.2
func (rs *RelayStream) Next() string
type System ¶ added in v0.36.0
type System struct { KVStore kvstore.KVStore MetadataCache cache.Cache32[ProfileMetadata] RelayListCache cache.Cache32[GenericList[Relay]] FollowListCache cache.Cache32[GenericList[ProfileRef]] MuteListCache cache.Cache32[GenericList[ProfileRef]] BookmarkListCache cache.Cache32[GenericList[EventRef]] PinListCache cache.Cache32[GenericList[EventRef]] BlockedRelayListCache cache.Cache32[GenericList[RelayURL]] SearchRelayListCache cache.Cache32[GenericList[RelayURL]] TopicListCache cache.Cache32[GenericList[Topic]] RelaySetsCache cache.Cache32[GenericSets[RelayURL]] FollowSetsCache cache.Cache32[GenericSets[ProfileRef]] TopicSetsCache cache.Cache32[GenericSets[Topic]] Hints hints.HintsDB Pool *nostr.SimplePool RelayListRelays *RelayStream FollowListRelays *RelayStream MetadataRelays *RelayStream FallbackRelays *RelayStream JustIDRelays *RelayStream UserSearchRelays *RelayStream NoteSearchRelays *RelayStream Store eventstore.Store StoreRelay nostr.RelayStore // contains filtered or unexported fields }
func NewSystem ¶ added in v0.36.0
func NewSystem(mods ...SystemModifier) *System
func (*System) FetchBlockedRelayList ¶ added in v0.46.0
func (*System) FetchBookmarkList ¶ added in v0.46.0
func (*System) FetchFeedPage ¶ added in v0.48.1
func (sys *System) FetchFeedPage( ctx context.Context, pubkeys []string, kinds []int, until nostr.Timestamp, totalLimit int, ) ([]*nostr.Event, error)
FetchFeedNextPage fetches historical events from the given pubkeys in descending order starting from the given until timestamp. The limit argument is just a hint of how much content you want for the entire list, it isn't guaranteed that this quantity of events will be returned -- it could be more or less.
It relies on KVStore's latestKey and oldestKey in order to determine if we should go to relays to ask for events or if we should just return what we have stored locally.
func (*System) FetchFollowList ¶ added in v0.36.0
func (sys *System) FetchFollowList(ctx context.Context, pubkey string) GenericList[ProfileRef]
func (*System) FetchFollowSets ¶ added in v0.46.0
func (sys *System) FetchFollowSets(ctx context.Context, pubkey string) GenericSets[ProfileRef]
func (*System) FetchInboxRelays ¶ added in v0.48.3
FetchWriteRelays just reads relays from a kind:10002, that's the only canonical place where a user reveals the relays they intend to receive notifications from.
func (*System) FetchMuteList ¶ added in v0.36.0
func (sys *System) FetchMuteList(ctx context.Context, pubkey string) GenericList[ProfileRef]
func (*System) FetchOutboxRelays ¶ added in v0.36.0
FetchOutboxRelays uses a bunch of heuristics and locally stored data about many relays, including hints, tags, NIP-05, past attempts at fetching data from a user from a given relay, including successes and failures, and the "write" relays of kind:10002, in order to determine the best possible list of relays where a user might be currently publishing their events to.
func (*System) FetchPinList ¶ added in v0.46.0
func (System) FetchProfileFromInput ¶ added in v0.36.0
func (sys System) FetchProfileFromInput(ctx context.Context, nip19OrNip05Code string) (ProfileMetadata, error)
FetchProfileFromInput takes an nprofile, npub, nip05 or hex pubkey and returns a ProfileMetadata, updating the hintsDB in the process with any eventual relay hints
func (*System) FetchProfileMetadata ¶ added in v0.36.0
func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey string) (pm ProfileMetadata)
FetchProfileMetadata fetches metadata for a given user from the local cache, or from the local store, or, failing these, from the target user's defined outbox relays -- then caches the result.
func (*System) FetchRelayList ¶ added in v0.46.0
func (*System) FetchRelaySets ¶ added in v0.46.0
func (*System) FetchSearchRelayList ¶ added in v0.46.0
func (*System) FetchSpecificEvent ¶ added in v0.38.2
func (sys *System) FetchSpecificEvent( ctx context.Context, pointer nostr.Pointer, withRelays bool, ) (event *nostr.Event, successRelays []string, err error)
FetchSpecificEvent tries to get a specific event from a NIP-19 code using whatever means necessary.
func (*System) FetchSpecificEventFromInput ¶ added in v0.46.0
func (sys *System) FetchSpecificEventFromInput( ctx context.Context, input string, withRelays bool, ) (event *nostr.Event, successRelays []string, err error)
FetchSpecificEventFromInput tries to get a specific event from a NIP-19 code using whatever means necessary.
func (*System) FetchTopicList ¶ added in v0.46.0
func (*System) FetchTopicSets ¶ added in v0.46.0
func (*System) FetchWriteRelays ¶ added in v0.49.3
FetchWriteRelays just reads relays from a kind:10002, it's different than FetchOutboxRelays, which relies on other data and heuristics besides kind:10002.
Use FetchWriteRelays when deciding where to publish on behalf of a user, but FetchOutboxRelays when deciding from where to read notes authored by other users.
func (*System) GetEventRelays ¶ added in v0.47.0
GetEventRelays returns all known relay URLs that have been seen to carry the given event.
func (*System) SearchUsers ¶ added in v0.36.0
func (sys *System) SearchUsers(ctx context.Context, query string) []ProfileMetadata
func (*System) StreamLiveFeed ¶ added in v0.48.1
func (sys *System) StreamLiveFeed( ctx context.Context, pubkeys []string, kinds []int, ) (<-chan *nostr.Event, error)
StreamPubkeysForward starts listening for new events from the given pubkeys, taking into account their outbox relays. It returns a channel that emits events continuously. The events are fetched from the time of the last seen event for each pubkey (stored in KVStore) onwards.
func (*System) TrackEventHints ¶ added in v0.37.0
func (sys *System) TrackEventHints(ie nostr.RelayEvent)
TrackEventHints is meant to be used standalone as an argument to WithEventMiddleware() when you're not interested in tracking relays associated to event ids.
func (*System) TrackEventHintsAndRelays ¶ added in v0.47.0
func (sys *System) TrackEventHintsAndRelays(ie nostr.RelayEvent)
TrackEventHintsAndRelays is meant to be as an argument to WithEventMiddleware() when you're interested in tracking relays associated to event ids as well as feeding hints to the HintsDB.
func (*System) TrackEventRelaysD ¶ added in v0.47.0
TrackEventRelaysD is a companion to TrackEventRelays meant to be used with WithDuplicateMiddleware()
type SystemModifier ¶ added in v0.36.0
type SystemModifier func(sys *System)
func WithFallbackRelays ¶ added in v0.36.0
func WithFallbackRelays(list []string) SystemModifier
func WithFollowListCache ¶ added in v0.36.0
func WithFollowListCache(cache cache.Cache32[GenericList[ProfileRef]]) SystemModifier
func WithFollowListRelays ¶ added in v0.36.0
func WithFollowListRelays(list []string) SystemModifier
func WithHintsDB ¶ added in v0.36.0
func WithHintsDB(hdb hints.HintsDB) SystemModifier
func WithJustIDRelays ¶ added in v0.38.2
func WithJustIDRelays(list []string) SystemModifier
func WithKVStore ¶ added in v0.47.0
func WithKVStore(store kvstore.KVStore) SystemModifier
func WithMetadataCache ¶ added in v0.36.0
func WithMetadataCache(cache cache.Cache32[ProfileMetadata]) SystemModifier
func WithMetadataRelays ¶ added in v0.36.0
func WithMetadataRelays(list []string) SystemModifier
func WithNoteSearchRelays ¶ added in v0.36.0
func WithNoteSearchRelays(list []string) SystemModifier
func WithRelayListCache ¶ added in v0.36.0
func WithRelayListCache(cache cache.Cache32[GenericList[Relay]]) SystemModifier
func WithRelayListRelays ¶ added in v0.36.0
func WithRelayListRelays(list []string) SystemModifier
func WithStore ¶ added in v0.36.0
func WithStore(store eventstore.Store) SystemModifier
func WithUserSearchRelays ¶ added in v0.36.0
func WithUserSearchRelays(list []string) SystemModifier
type TagItemWithValue ¶ added in v0.36.0
type TagItemWithValue interface {
Value() string
}