enhance spider with rate limit handling, follow list updates, and improved reconnect logic; bump version to v0.29.0
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled

also reduces CPU load for spider, and minor CORS fixes
This commit is contained in:
2025-11-14 21:15:24 +00:00
parent 24eef5b5a8
commit bf8d912063
10 changed files with 266 additions and 51 deletions

View File

@@ -46,6 +46,8 @@ type Follows struct {
subsCancel context.CancelFunc
// Track last follow list fetch time
lastFollowListFetch time.Time
// Callback for external notification of follow list changes
onFollowListUpdate func()
}
func (f *Follows) Configure(cfg ...any) (err error) {
@@ -314,7 +316,6 @@ func (f *Follows) adminRelays() (urls []string) {
"wss://nostr.wine",
"wss://nos.lol",
"wss://relay.damus.io",
"wss://nostr.band",
}
log.I.F("using failover relays: %v", failoverRelays)
for _, relay := range failoverRelays {
@@ -933,6 +934,13 @@ func (f *Follows) AdminRelays() []string {
return f.adminRelays()
}
// SetFollowListUpdateCallback sets a callback to be called when the follow list is updated
func (f *Follows) SetFollowListUpdateCallback(callback func()) {
f.followsMx.Lock()
defer f.followsMx.Unlock()
f.onFollowListUpdate = callback
}
// AddFollow appends a pubkey to the in-memory follows list if not already present
// and signals the syncer to refresh subscriptions.
func (f *Follows) AddFollow(pub []byte) {
@@ -961,6 +969,10 @@ func (f *Follows) AddFollow(pub []byte) {
// if channel is full or not yet listened to, ignore
}
}
// notify external listeners (e.g., spider)
if f.onFollowListUpdate != nil {
go f.onFollowListUpdate()
}
}
func init() {