Some checks failed
Go / build-and-release (push) Has been cancelled
- Implement NIP-NRC protocol for remote relay access through public relay tunnel - Add NRC bridge service with NIP-44 encrypted message tunneling - Add NRC client library for applications - Add session management with subscription tracking and expiry - Add URI parsing for nostr+relayconnect:// scheme with secret and CAT auth - Add NRC API endpoints for connection management (create/list/delete/get-uri) - Add RelayConnectView.svelte component for managing NRC connections in web UI - Add NRC database storage for connection secrets and labels - Add NRC CLI commands (generate, list, revoke) - Add support for Cashu Access Tokens (CAT) in NRC URIs - Add ScopeNRC constant for Cashu token scope - Add wasm build infrastructure and stub files Files modified: - app/config/config.go: NRC configuration options - app/handle-nrc.go: New API handlers for NRC connections - app/main.go: NRC bridge startup integration - app/server.go: Register NRC API routes - app/web/src/App.svelte: Add Relay Connect tab - app/web/src/RelayConnectView.svelte: New NRC management component - app/web/src/api.js: NRC API client functions - main.go: NRC CLI command handlers - pkg/bunker/acl_adapter.go: Add NRC scope mapping - pkg/cashu/token/token.go: Add ScopeNRC constant - pkg/database/nrc.go: NRC connection storage - pkg/protocol/nrc/: New NRC protocol implementation - docs/NIP-NRC.md: NIP specification document 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
//go:build js && wasm
|
|
|
|
// Package bufpool provides buffer pools for reducing GC pressure in hot paths.
|
|
// This is the WASM version which uses simple allocations since sync.Pool
|
|
// behavior differs in WASM environments.
|
|
package bufpool
|
|
|
|
import (
|
|
"bytes"
|
|
)
|
|
|
|
const (
|
|
// SmallBufferSize for index keys (8-64 bytes typical)
|
|
SmallBufferSize = 64
|
|
|
|
// MediumBufferSize for event encoding (300-1000 bytes typical)
|
|
MediumBufferSize = 1024
|
|
)
|
|
|
|
// GetSmall returns a small buffer (64 bytes).
|
|
// In WASM, we simply allocate new buffers as sync.Pool is less effective.
|
|
func GetSmall() *bytes.Buffer {
|
|
return bytes.NewBuffer(make([]byte, 0, SmallBufferSize))
|
|
}
|
|
|
|
// PutSmall is a no-op in WASM; the buffer will be garbage collected.
|
|
func PutSmall(buf *bytes.Buffer) {
|
|
// No-op in WASM
|
|
}
|
|
|
|
// GetMedium returns a medium buffer (1KB).
|
|
func GetMedium() *bytes.Buffer {
|
|
return bytes.NewBuffer(make([]byte, 0, MediumBufferSize))
|
|
}
|
|
|
|
// PutMedium is a no-op in WASM; the buffer will be garbage collected.
|
|
func PutMedium(buf *bytes.Buffer) {
|
|
// No-op in WASM
|
|
}
|
|
|
|
// CopyBytes copies the buffer contents to a new slice.
|
|
func CopyBytes(buf *bytes.Buffer) []byte {
|
|
if buf == nil || buf.Len() == 0 {
|
|
return nil
|
|
}
|
|
result := make([]byte, buf.Len())
|
|
copy(result, buf.Bytes())
|
|
return result
|
|
}
|