From 40535e6b1931c62d114df87da691d493f60a3cd8 Mon Sep 17 00:00:00 2001 From: Kay Date: Tue, 25 Mar 2025 14:37:14 +0000 Subject: [PATCH] feat(nip11): update to nips pr nostr-protocol/nip#1821 --- nip11/types.go | 24 +++++++++++++----------- nip96/nip96_test.go | 4 ++-- nipb0/blossom/download.go | 2 +- sdk/kvstore/interface.go | 6 +++--- sdk/kvstore/lmdb/store.go | 4 ++-- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/nip11/types.go b/nip11/types.go index a33d276..0b11d26 100644 --- a/nip11/types.go +++ b/nip11/types.go @@ -43,17 +43,19 @@ func (info *RelayInformationDocument) AddSupportedNIPs(numbers []int) { } type RelayLimitationDocument struct { - MaxMessageLength int `json:"max_message_length,omitempty"` - MaxSubscriptions int `json:"max_subscriptions,omitempty"` - MaxFilters int `json:"max_filters,omitempty"` - MaxLimit int `json:"max_limit,omitempty"` - MaxSubidLength int `json:"max_subid_length,omitempty"` - MaxEventTags int `json:"max_event_tags,omitempty"` - MaxContentLength int `json:"max_content_length,omitempty"` - MinPowDifficulty int `json:"min_pow_difficulty,omitempty"` - AuthRequired bool `json:"auth_required"` - PaymentRequired bool `json:"payment_required"` - RestrictedWrites bool `json:"restricted_writes"` + MaxMessageLength int `json:"max_message_length,omitempty"` + MaxSubscriptions int `json:"max_subscriptions,omitempty"` + MaxLimit int `json:"max_limit,omitempty"` + DefaultLimit int `json:"default_limit,omitempty"` + MaxSubidLength int `json:"max_subid_length,omitempty"` + MaxEventTags int `json:"max_event_tags,omitempty"` + MaxContentLength int `json:"max_content_length,omitempty"` + MinPowDifficulty int `json:"min_pow_difficulty,omitempty"` + CreatedAtLowerLimit int64 `json:"created_at_lower_limit"` + CreatedAtUpperLimit int64 `json:"created_at_upper_limit"` + AuthRequired bool `json:"auth_required"` + PaymentRequired bool `json:"payment_required"` + RestrictedWrites bool `json:"restricted_writes"` } type RelayFeesDocument struct { diff --git a/nip96/nip96_test.go b/nip96/nip96_test.go index 3ddf82e..08d0dd9 100644 --- a/nip96/nip96_test.go +++ b/nip96/nip96_test.go @@ -21,8 +21,8 @@ func TestUpload(t *testing.T) { ctx := context.Background() resp, err := Upload(ctx, UploadRequest{ Host: "https://nostr.build/api/v2/nip96/upload", - //Host: "https://nostrcheck.me/api/v2/media", - //Host: "https://nostrage.com/api/v2/media", + // Host: "https://nostrcheck.me/api/v2/media", + // Host: "https://nostrage.com/api/v2/media", SK: nostr.GeneratePrivateKey(), SignPayload: true, File: img, diff --git a/nipb0/blossom/download.go b/nipb0/blossom/download.go index f3ba5e5..a4f62e4 100644 --- a/nipb0/blossom/download.go +++ b/nipb0/blossom/download.go @@ -67,7 +67,7 @@ func (c *Client) DownloadToFile(ctx context.Context, hash string, filePath strin return fmt.Errorf("%s is not present in %s: %d", hash, c.mediaserver, resp.StatusCode) } - file, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) + file, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return fmt.Errorf("failed to create file %s for %s: %w", filePath, hash, err) } diff --git a/sdk/kvstore/interface.go b/sdk/kvstore/interface.go index c16b50a..b374a40 100644 --- a/sdk/kvstore/interface.go +++ b/sdk/kvstore/interface.go @@ -4,13 +4,13 @@ package kvstore type KVStore interface { // Get retrieves a value for a given key. Returns nil if not found. Get(key []byte) ([]byte, error) - + // Set stores a value for a given key Set(key []byte, value []byte) error - + // Delete removes a key and its value Delete(key []byte) error - + // Close releases any resources held by the store Close() error diff --git a/sdk/kvstore/lmdb/store.go b/sdk/kvstore/lmdb/store.go index 5863d9b..189c793 100644 --- a/sdk/kvstore/lmdb/store.go +++ b/sdk/kvstore/lmdb/store.go @@ -16,7 +16,7 @@ type Store struct { func NewStore(path string) (*Store, error) { // create directory if it doesn't exist - if err := os.MkdirAll(path, 0755); err != nil { + if err := os.MkdirAll(path, 0o755); err != nil { return nil, err } @@ -31,7 +31,7 @@ func NewStore(path string) (*Store, error) { env.SetMapSize(1 << 30) // 1GB // open the environment - if err := env.Open(path, lmdb.NoTLS|lmdb.WriteMap, 0644); err != nil { + if err := env.Open(path, lmdb.NoTLS|lmdb.WriteMap, 0o644); err != nil { return nil, err }