nip46: rename Pool to Signer.

This commit is contained in:
fiatjaf
2023-12-01 20:50:00 -03:00
parent c606a43c07
commit 2b9b4dfa2f

View File

@@ -75,7 +75,7 @@ func (s Session) MakeResponse(
return resp, evt, nil return resp, evt, nil
} }
type Pool struct { type Signer struct {
secretKey string secretKey string
sessionKeys []string sessionKeys []string
@@ -89,15 +89,15 @@ type relayReadWrite struct {
Write bool `json:"write"` Write bool `json:"write"`
} }
func NewPool(secretKey string) Pool { func NewSigner(secretKey string) Signer {
return Pool{secretKey: secretKey} return Signer{secretKey: secretKey}
} }
func (p *Pool) AddRelay(url string, read bool, write bool) { func (p *Signer) AddRelay(url string, read bool, write bool) {
p.RelaysToAdvertise[url] = relayReadWrite{read, write} p.RelaysToAdvertise[url] = relayReadWrite{read, write}
} }
func (p *Pool) GetSession(clientPubkey string) (Session, error) { func (p *Signer) GetSession(clientPubkey string) (Session, error) {
idx, exists := slices.BinarySearch(p.sessionKeys, clientPubkey) idx, exists := slices.BinarySearch(p.sessionKeys, clientPubkey)
if exists { if exists {
return p.sessions[idx], nil return p.sessions[idx], nil
@@ -123,7 +123,7 @@ func (p *Pool) GetSession(clientPubkey string) (Session, error) {
return session, nil return session, nil
} }
func (p *Pool) HandleRequest(event *nostr.Event) (req Request, resp Response, eventResponse nostr.Event, harmless bool, err error) { func (p *Signer) HandleRequest(event *nostr.Event) (req Request, resp Response, eventResponse nostr.Event, harmless bool, err error) {
if event.Kind != nostr.KindNostrConnect { if event.Kind != nostr.KindNostrConnect {
return req, resp, eventResponse, false, return req, resp, eventResponse, false,
fmt.Errorf("event kind is %d, but we expected %d", event.Kind, nostr.KindNostrConnect) fmt.Errorf("event kind is %d, but we expected %d", event.Kind, nostr.KindNostrConnect)