allow using libsecp256k1 for signature verification in subscriptions.

This commit is contained in:
fiatjaf
2024-05-29 17:08:15 -03:00
parent 31e0645afe
commit d06f61136d
3 changed files with 63 additions and 20 deletions

11
pool.go
View File

@@ -22,6 +22,9 @@ type SimplePool struct {
authHandler func(*Event) error
cancel context.CancelFunc
// custom things not often used
SignatureChecker func(Event) bool
}
type DirectedFilters struct {
@@ -85,7 +88,13 @@ func (pool *SimplePool) EnsureRelay(url string) (*Relay, error) {
// we use this ctx here so when the pool dies everything dies
ctx, cancel := context.WithTimeout(pool.Context, time.Second*15)
defer cancel()
if relay, err = RelayConnect(ctx, nm); err != nil {
opts := make([]RelayOption, 0, 1)
if pool.SignatureChecker != nil {
opts = append(opts, WithSignatureChecker(pool.SignatureChecker))
}
if relay, err = RelayConnect(ctx, nm, opts...); err != nil {
return nil, fmt.Errorf("failed to connect: %w", err)
}