mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 13:22:56 +01:00
debug
This commit is contained in:
parent
446b104990
commit
2943d05bbb
@ -3,9 +3,11 @@ package nostr
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Subscription struct {
|
||||
@ -72,6 +74,10 @@ func (sub *Subscription) start() {
|
||||
select {
|
||||
case sub.Events <- event:
|
||||
case <-sub.Context.Done():
|
||||
log.Println("~ gndbg ~ discarding event on canceled sub: ", sub.GetID())
|
||||
case <-time.After(60 * time.Minute):
|
||||
log.Println("~ gndbg ~ spent 60 minutes waiting: ", sub.GetID(), " ", sub.Filters.String())
|
||||
sub.Unsub()
|
||||
}
|
||||
}
|
||||
mu.Unlock()
|
||||
@ -93,6 +99,10 @@ func (sub *Subscription) start() {
|
||||
// Unsub closes the subscription, sending "CLOSE" to relay as in NIP-01.
|
||||
// Unsub() also closes the channel sub.Events and makes a new one.
|
||||
func (sub *Subscription) Unsub() {
|
||||
if sub.label == "hf" && sub.Context.Err() == nil {
|
||||
log.Println("~ gndbg ~ closing sub: ", sub.GetID())
|
||||
}
|
||||
|
||||
// cancel the context (if it's not canceled already)
|
||||
sub.cancel()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user