diff --git a/.gitignore b/.gitignore index 1b30163..3cc9a9d 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ node_modules/** # and others /go.work.sum /secp256k1/ +cmd/benchmark/external # But not these files... !/.gitignore @@ -87,6 +88,9 @@ node_modules/** !.gitignore !version !out.jsonl +!Dockerfile* +!strfry.conf +!config.toml # ...even if they are in subdirectories !*/ /blocklist.json @@ -108,3 +112,4 @@ pkg/database/testrealy /.idea/inspectionProfiles/Project_Default.xml /.idea/.name /ctxproxy.config.yml +cmd/benchmark/external/** \ No newline at end of file diff --git a/app/handle-auth.go b/app/handle-auth.go index 2896df5..011bc41 100644 --- a/app/handle-auth.go +++ b/app/handle-auth.go @@ -1,11 +1,11 @@ package app import ( - "encoders.orly/envelopes/authenvelope" - "encoders.orly/envelopes/okenvelope" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "protocol.orly/auth" + "next.orly.dev/pkg/encoders/envelopes/authenvelope" + "next.orly.dev/pkg/encoders/envelopes/okenvelope" + "next.orly.dev/pkg/protocol/auth" ) func (l *Listener) HandleAuth(b []byte) (err error) { diff --git a/app/handle-close.go b/app/handle-close.go index 7c8a747..044ae54 100644 --- a/app/handle-close.go +++ b/app/handle-close.go @@ -3,9 +3,9 @@ package app import ( "errors" - "encoders.orly/envelopes/closeenvelope" "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/encoders/envelopes/closeenvelope" ) // HandleClose processes a CLOSE envelope by unmarshalling the request, diff --git a/app/handle-delete.go b/app/handle-delete.go index 05e3738..a6574e8 100644 --- a/app/handle-delete.go +++ b/app/handle-delete.go @@ -3,18 +3,18 @@ package app import ( "fmt" - "database.orly/indexes/types" - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/ints" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/tag/atag" "lol.mleku.dev/chk" "lol.mleku.dev/log" - utils "utils.orly" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/tag/atag" + utils "next.orly.dev/pkg/utils" ) func (l *Listener) GetSerialsFromFilter(f *filter.F) ( diff --git a/app/handle-event.go b/app/handle-event.go index 27e7bd2..ac278d7 100644 --- a/app/handle-event.go +++ b/app/handle-event.go @@ -6,15 +6,15 @@ import ( "strings" "time" - acl "acl.orly" - "encoders.orly/envelopes/authenvelope" - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/envelopes/okenvelope" - "encoders.orly/kind" - "encoders.orly/reason" "lol.mleku.dev/chk" "lol.mleku.dev/log" - utils "utils.orly" + acl "next.orly.dev/pkg/acl" + "next.orly.dev/pkg/encoders/envelopes/authenvelope" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/envelopes/okenvelope" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/reason" + utils "next.orly.dev/pkg/utils" ) func (l *Listener) HandleEvent(msg []byte) (err error) { diff --git a/app/handle-message.go b/app/handle-message.go index 9ae36da..99b0c64 100644 --- a/app/handle-message.go +++ b/app/handle-message.go @@ -1,15 +1,15 @@ package app import ( - "encoders.orly/envelopes" - "encoders.orly/envelopes/authenvelope" - "encoders.orly/envelopes/closeenvelope" - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/envelopes/noticeenvelope" - "encoders.orly/envelopes/reqenvelope" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/envelopes/authenvelope" + "next.orly.dev/pkg/encoders/envelopes/closeenvelope" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/envelopes/noticeenvelope" + "next.orly.dev/pkg/encoders/envelopes/reqenvelope" ) func (l *Listener) HandleMessage(msg []byte, remote string) { diff --git a/app/handle-relayinfo.go b/app/handle-relayinfo.go index b4d2701..5976c9c 100644 --- a/app/handle-relayinfo.go +++ b/app/handle-relayinfo.go @@ -7,8 +7,8 @@ import ( "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/protocol/relayinfo" "next.orly.dev/pkg/version" - "protocol.orly/relayinfo" ) // HandleRelayInfo generates and returns a relay information document in JSON diff --git a/app/handle-req.go b/app/handle-req.go index 8c92996..d097c45 100644 --- a/app/handle-req.go +++ b/app/handle-req.go @@ -6,25 +6,25 @@ import ( "fmt" "time" - acl "acl.orly" - "encoders.orly/envelopes/authenvelope" - "encoders.orly/envelopes/closedenvelope" - "encoders.orly/envelopes/eoseenvelope" - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/envelopes/okenvelope" - "encoders.orly/envelopes/reqenvelope" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/reason" - "encoders.orly/tag" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" "lol.mleku.dev/log" - utils "utils.orly" - "utils.orly/normalize" - "utils.orly/pointers" + acl "next.orly.dev/pkg/acl" + "next.orly.dev/pkg/encoders/envelopes/authenvelope" + "next.orly.dev/pkg/encoders/envelopes/closedenvelope" + "next.orly.dev/pkg/encoders/envelopes/eoseenvelope" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/envelopes/okenvelope" + "next.orly.dev/pkg/encoders/envelopes/reqenvelope" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/reason" + "next.orly.dev/pkg/encoders/tag" + utils "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/normalize" + "next.orly.dev/pkg/utils/pointers" ) func (l *Listener) HandleReq(msg []byte) (err error) { diff --git a/app/handle-websocket.go b/app/handle-websocket.go index 2a1427c..418ea5b 100644 --- a/app/handle-websocket.go +++ b/app/handle-websocket.go @@ -7,12 +7,12 @@ import ( "strings" "time" - "encoders.orly/envelopes/authenvelope" - "encoders.orly/hex" "github.com/coder/websocket" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly/units" + "next.orly.dev/pkg/encoders/envelopes/authenvelope" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils/units" ) const ( diff --git a/app/listener.go b/app/listener.go index dfc9b0c..6a901f1 100644 --- a/app/listener.go +++ b/app/listener.go @@ -6,7 +6,7 @@ import ( "github.com/coder/websocket" "lol.mleku.dev/chk" - "utils.orly/atomic" + "next.orly.dev/pkg/utils/atomic" ) type Listener struct { diff --git a/app/main.go b/app/main.go index 884fba8..ee6caca 100644 --- a/app/main.go +++ b/app/main.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - database "database.orly" - "encoders.orly/bech32encoding" "lol.mleku.dev/chk" "lol.mleku.dev/log" "next.orly.dev/app/config" - "protocol.orly/publish" + database "next.orly.dev/pkg/database" + "next.orly.dev/pkg/encoders/bech32encoding" + "next.orly.dev/pkg/protocol/publish" ) func Run( diff --git a/app/ok.go b/app/ok.go index 3923373..8108d93 100644 --- a/app/ok.go +++ b/app/ok.go @@ -1,9 +1,9 @@ package app import ( - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/envelopes/okenvelope" - "encoders.orly/reason" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/envelopes/okenvelope" + "next.orly.dev/pkg/encoders/reason" ) // OK represents a function that processes events or operations, using provided diff --git a/app/publisher.go b/app/publisher.go index 996aef0..c5fa4f1 100644 --- a/app/publisher.go +++ b/app/publisher.go @@ -5,17 +5,17 @@ import ( "fmt" "sync" - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" "github.com/coder/websocket" - "interfaces.orly/publisher" - "interfaces.orly/typer" "lol.mleku.dev/chk" "lol.mleku.dev/log" - utils "utils.orly" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/interfaces/publisher" + "next.orly.dev/pkg/interfaces/typer" + utils "next.orly.dev/pkg/utils" ) const Type = "socketapi" diff --git a/app/server.go b/app/server.go index 3b3344b..faec112 100644 --- a/app/server.go +++ b/app/server.go @@ -6,10 +6,10 @@ import ( "strconv" "strings" - "database.orly" "lol.mleku.dev/chk" "next.orly.dev/app/config" - "protocol.orly/publish" + "next.orly.dev/pkg/database" + "next.orly.dev/pkg/protocol/publish" ) type Server struct { diff --git a/cmd/benchmark/Dockerfile.benchmark b/cmd/benchmark/Dockerfile.benchmark new file mode 100644 index 0000000..ca55e7c --- /dev/null +++ b/cmd/benchmark/Dockerfile.benchmark @@ -0,0 +1,46 @@ +# Dockerfile for benchmark runner +FROM golang:1.25-alpine AS builder + +# Install build dependencies +RUN apk add --no-cache git ca-certificates + +# Set working directory +WORKDIR /build + +# Copy go modules +COPY go.mod go.sum ./ +RUN go mod download + +# Copy source code +COPY . . + +# Build the benchmark tool +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o benchmark cmd/benchmark/main.go + +# Final stage +FROM alpine:latest + +# Install runtime dependencies +RUN apk --no-cache add ca-certificates curl wget + +WORKDIR /app + +# Copy benchmark binary +COPY --from=builder /build/benchmark /app/benchmark + +# Copy benchmark runner script +COPY cmd/benchmark/benchmark-runner.sh /app/benchmark-runner + +# Make scripts executable +RUN chmod +x /app/benchmark-runner + +# Create reports directory +RUN mkdir -p /reports + +# Environment variables +ENV BENCHMARK_EVENTS=10000 +ENV BENCHMARK_WORKERS=8 +ENV BENCHMARK_DURATION=60s + +# Run the benchmark runner +CMD ["/app/benchmark-runner"] \ No newline at end of file diff --git a/cmd/benchmark/Dockerfile.khatru-badger b/cmd/benchmark/Dockerfile.khatru-badger new file mode 100644 index 0000000..40125b2 --- /dev/null +++ b/cmd/benchmark/Dockerfile.khatru-badger @@ -0,0 +1,23 @@ +FROM golang:1.25-alpine AS builder + +RUN apk add --no-cache git ca-certificates + +WORKDIR /build +COPY . . + +# Build the basic-badger example +RUN cd examples/basic-badger && \ + go mod tidy && \ + CGO_ENABLED=0 go build -o khatru-badger . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates wget +WORKDIR /app +COPY --from=builder /build/examples/basic-badger/khatru-badger /app/ +RUN mkdir -p /data +EXPOSE 8080 +ENV DATABASE_PATH=/data/badger +ENV PORT=8080 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 +CMD ["/app/khatru-badger"] diff --git a/cmd/benchmark/Dockerfile.khatru-sqlite b/cmd/benchmark/Dockerfile.khatru-sqlite new file mode 100644 index 0000000..5366ae1 --- /dev/null +++ b/cmd/benchmark/Dockerfile.khatru-sqlite @@ -0,0 +1,23 @@ +FROM golang:1.25-alpine AS builder + +RUN apk add --no-cache git ca-certificates sqlite-dev gcc musl-dev + +WORKDIR /build +COPY . . + +# Build the basic-sqlite example +RUN cd examples/basic-sqlite3 && \ + go mod tidy && \ + CGO_ENABLED=1 go build -o khatru-sqlite . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates sqlite wget +WORKDIR /app +COPY --from=builder /build/examples/basic-sqlite3/khatru-sqlite /app/ +RUN mkdir -p /data +EXPOSE 8080 +ENV DATABASE_PATH=/data/khatru.db +ENV PORT=8080 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 +CMD ["/app/khatru-sqlite"] diff --git a/cmd/benchmark/Dockerfile.next-orly b/cmd/benchmark/Dockerfile.next-orly new file mode 100644 index 0000000..b196301 --- /dev/null +++ b/cmd/benchmark/Dockerfile.next-orly @@ -0,0 +1,80 @@ +# Dockerfile for next.orly.dev relay +FROM ubuntu:22.04 as builder + +# Set environment variables +ARG GOLANG_VERSION=1.25.1 + +# Update package list and install dependencies +RUN apt-get update && \ + apt-get install -y wget ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# Download Go binary +RUN wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz && \ + rm -rf /usr/local/go && \ + tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz && \ + rm go${GOLANG_VERSION}.linux-amd64.tar.gz + +# Set PATH environment variable +ENV PATH="/usr/local/go/bin:${PATH}" + +# Verify installation +RUN go version + +RUN apt update && \ + apt -y install build-essential autoconf libtool git wget +RUN cd /tmp && \ + rm -rf secp256k1 && \ + git clone https://github.com/bitcoin-core/secp256k1.git && \ + cd secp256k1 && \ + git checkout v0.6.0 && \ + git submodule init && \ + git submodule update && \ + ./autogen.sh && \ + ./configure --enable-module-schnorrsig --enable-module-ecdh --prefix=/usr && \ + make -j1 && \ + make install + +# Set working directory +WORKDIR /build + +# Copy go modules +COPY go.mod go.sum ./ +RUN go mod download + +# Copy source code +COPY . . + +# Build the relay +RUN CGO_ENABLED=1 GOOS=linux go build -o relay . + +# Final stage +FROM ubuntu:22.04 + +# Install runtime dependencies +RUN apt-get update && apt-get install -y ca-certificates curl libsecp256k1-0 libsecp256k1-dev && rm -rf /var/lib/apt/lists/* && \ + ln -sf /usr/lib/x86_64-linux-gnu/libsecp256k1.so.0 /usr/lib/x86_64-linux-gnu/libsecp256k1.so.5 + +WORKDIR /app + +# Copy binary from builder +COPY --from=builder /build/relay /app/relay + +# Create data directory +RUN mkdir -p /data + +# Expose port +EXPOSE 8080 + +# Set environment variables +ENV DATA_DIR=/data +ENV LISTEN=0.0.0.0 +ENV PORT=8080 +ENV LOG_LEVEL=info + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8080 || exit 1 + +# Run the relay +CMD ["/app/relay"] \ No newline at end of file diff --git a/cmd/benchmark/Dockerfile.nostr-rs-relay b/cmd/benchmark/Dockerfile.nostr-rs-relay new file mode 100644 index 0000000..f666c10 --- /dev/null +++ b/cmd/benchmark/Dockerfile.nostr-rs-relay @@ -0,0 +1,33 @@ +FROM ubuntu:22.04 AS builder + +RUN apt-get update && apt-get install -y \ + curl \ + build-essential \ + libsqlite3-dev \ + pkg-config \ + protobuf-compiler \ + && rm -rf /var/lib/apt/lists/* + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +WORKDIR /build +COPY . . + +# Build the relay +RUN cargo build --release + +FROM ubuntu:22.04 +RUN apt-get update && apt-get install -y ca-certificates sqlite3 wget && rm -rf /var/lib/apt/lists/* +WORKDIR /app +COPY --from=builder /build/target/release/nostr-rs-relay /app/ +RUN mkdir -p /data + +EXPOSE 8080 +ENV RUST_LOG=info + +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 + +CMD ["/app/nostr-rs-relay"] diff --git a/cmd/benchmark/Dockerfile.relayer-basic b/cmd/benchmark/Dockerfile.relayer-basic new file mode 100644 index 0000000..e66093a --- /dev/null +++ b/cmd/benchmark/Dockerfile.relayer-basic @@ -0,0 +1,23 @@ +FROM golang:1.25-alpine AS builder + +RUN apk add --no-cache git ca-certificates sqlite-dev gcc musl-dev + +WORKDIR /build +COPY . . + +# Build the basic example +RUN cd examples/basic && \ + go mod tidy && \ + CGO_ENABLED=1 go build -o relayer-basic . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates sqlite wget +WORKDIR /app +COPY --from=builder /build/examples/basic/relayer-basic /app/ +RUN mkdir -p /data +EXPOSE 8080 +ENV DATABASE_PATH=/data/relayer.db +ENV PORT=8080 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 +CMD ["/app/relayer-basic"] diff --git a/cmd/benchmark/Dockerfile.strfry b/cmd/benchmark/Dockerfile.strfry new file mode 100644 index 0000000..f7c514f --- /dev/null +++ b/cmd/benchmark/Dockerfile.strfry @@ -0,0 +1,54 @@ +FROM ubuntu:22.04 AS builder + +ENV DEBIAN_FRONTEND=noninteractive + +# Install build dependencies +RUN apt-get update && apt-get install -y git g++ make libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /build +COPY . . + +# Initialize git submodules +RUN git submodule update --init --recursive + +# Build strfry +RUN make setup-golpe && \ + make -j$(nproc) + +FROM ubuntu:22.04 +RUN apt-get update && apt-get install -y \ + liblmdb0 \ + libsecp256k1-0 \ + curl \ + bash \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY --from=builder /build/strfry /app/ +COPY --from=builder /build/strfry.conf /app/ + +# Create the data directory placeholder (may be masked by volume at runtime) +RUN mkdir -p /data && \ + chmod 755 /data + +# Update strfry.conf to bind to all interfaces and use port 8080 +RUN sed -i 's/bind = "127.0.0.1"/bind = "0.0.0.0"/' /app/strfry.conf && \ + sed -i 's/port = 7777/port = 8080/' /app/strfry.conf + +# Entrypoint ensures the LMDB directory exists inside the mounted volume before starting +ENV STRFRY_DB_PATH=/data/strfry.lmdb +RUN echo '#!/usr/bin/env bash' > /entrypoint.sh && \ + echo 'set -euo pipefail' >> /entrypoint.sh && \ + echo 'DB_PATH="${STRFRY_DB_PATH:-/data/strfry.lmdb}"' >> /entrypoint.sh && \ + echo 'mkdir -p "$DB_PATH"' >> /entrypoint.sh && \ + echo 'chown -R root:root "$(dirname "$DB_PATH")"' >> /entrypoint.sh && \ + echo 'exec /app/strfry relay' >> /entrypoint.sh && \ + chmod +x /entrypoint.sh + +EXPOSE 8080 + +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8080 || exit 1 + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/cmd/benchmark/README.md b/cmd/benchmark/README.md new file mode 100644 index 0000000..24e14cd --- /dev/null +++ b/cmd/benchmark/README.md @@ -0,0 +1,260 @@ +# Nostr Relay Benchmark Suite + +A comprehensive benchmarking system for testing and comparing the performance of multiple Nostr relay implementations, including: + +- **next.orly.dev** (this repository) - BadgerDB-based relay +- **Khatru** - SQLite and Badger variants +- **Relayer** - Basic example implementation +- **Strfry** - C++ LMDB-based relay +- **nostr-rs-relay** - Rust-based relay with SQLite + +## Features + +### Benchmark Tests + +1. **Peak Throughput Test** + - Tests maximum event ingestion rate + - Concurrent workers pushing events as fast as possible + - Measures events/second, latency distribution, success rate + +2. **Burst Pattern Test** + - Simulates real-world traffic patterns + - Alternating high-activity bursts and quiet periods + - Tests relay behavior under varying loads + +3. **Mixed Read/Write Test** + - Concurrent read and write operations + - Tests query performance while events are being ingested + - Measures combined throughput and latency + +### Performance Metrics + +- **Throughput**: Events processed per second +- **Latency**: Average, P95, and P99 response times +- **Success Rate**: Percentage of successful operations +- **Memory Usage**: Peak memory consumption during tests +- **Error Analysis**: Detailed error reporting and categorization + +### Reporting + +- Individual relay reports with detailed metrics +- Aggregate comparison report across all relays +- Comparison tables for easy performance analysis +- Timestamped results for tracking improvements over time + +## Quick Start + +### 1. Setup External Relays + +Run the setup script to download and configure all external relay repositories: + +```bash +cd cmd/benchmark +./setup-external-relays.sh +``` + +This will: +- Clone all external relay repositories +- Create Docker configurations for each relay +- Set up configuration files +- Create data and report directories + +### 2. Run Benchmarks + +Start all relays and run the benchmark suite: + +```bash +docker compose up --build +``` + +The system will: +- Build and start all relay containers +- Wait for all relays to become healthy +- Run benchmarks against each relay sequentially +- Generate individual and aggregate reports + +### 3. View Results + +Results are stored in the `reports/` directory with timestamps: + +```bash +# View the aggregate report +cat reports/run_YYYYMMDD_HHMMSS/aggregate_report.txt + +# View individual relay results +ls reports/run_YYYYMMDD_HHMMSS/ +``` + +## Architecture + +### Docker Compose Services + +| Service | Port | Description | +|---------|------|-------------| +| next-orly | 8001 | This repository's BadgerDB relay | +| khatru-sqlite | 8002 | Khatru with SQLite backend | +| khatru-badger | 8003 | Khatru with Badger backend | +| relayer-basic | 8004 | Basic relayer example | +| strfry | 8005 | Strfry C++ LMDB relay | +| nostr-rs-relay | 8006 | Rust SQLite relay | +| benchmark-runner | - | Orchestrates tests and aggregates results | + +### File Structure + +``` +cmd/benchmark/ +├── main.go # Benchmark tool implementation +├── docker-compose.yml # Service orchestration +├── setup-external-relays.sh # Repository setup script +├── benchmark-runner.sh # Test orchestration script +├── Dockerfile.next-orly # This repo's relay container +├── Dockerfile.benchmark # Benchmark runner container +├── Dockerfile.khatru-sqlite # Khatru SQLite variant +├── Dockerfile.khatru-badger # Khatru Badger variant +├── Dockerfile.relayer-basic # Relayer basic example +├── Dockerfile.strfry # Strfry relay +├── Dockerfile.nostr-rs-relay # Rust relay +├── configs/ +│ ├── strfry.conf # Strfry configuration +│ └── config.toml # nostr-rs-relay configuration +├── external/ # External relay repositories +├── data/ # Persistent data for each relay +└── reports/ # Benchmark results +``` + +## Configuration + +### Environment Variables + +The benchmark can be configured via environment variables in `docker-compose.yml`: + +```yaml +environment: + - BENCHMARK_EVENTS=10000 # Number of events per test + - BENCHMARK_WORKERS=8 # Concurrent workers + - BENCHMARK_DURATION=60s # Test duration + - BENCHMARK_TARGETS=... # Relay endpoints to test +``` + +### Custom Configuration + +1. **Modify test parameters**: Edit environment variables in `docker-compose.yml` +2. **Add new relays**: + - Add service to `docker-compose.yml` + - Create appropriate Dockerfile + - Update `BENCHMARK_TARGETS` environment variable +3. **Adjust relay configs**: Edit files in `configs/` directory + +## Manual Usage + +### Run Individual Relay + +```bash +# Build and run a specific relay +docker-compose up next-orly + +# Run benchmark against specific endpoint +./benchmark -datadir=/tmp/test -events=1000 -workers=4 +``` + +### Run Benchmark Tool Directly + +```bash +# Build the benchmark tool +go build -o benchmark main.go + +# Run with custom parameters +./benchmark \ + -datadir=/tmp/benchmark_db \ + -events=5000 \ + -workers=4 \ + -duration=30s +``` + +## Benchmark Results Interpretation + +### Peak Throughput Test +- **High events/sec**: Good write performance +- **Low latency**: Efficient event processing +- **High success rate**: Stable under load + +### Burst Pattern Test +- **Consistent performance**: Good handling of variable loads +- **Low P95/P99 latency**: Predictable response times +- **No errors during bursts**: Robust queuing/buffering + +### Mixed Read/Write Test +- **Balanced throughput**: Good concurrent operation handling +- **Low read latency**: Efficient query processing +- **Stable write performance**: Queries don't significantly impact writes + +## Development + +### Adding New Tests + +1. Extend the `Benchmark` struct in `main.go` +2. Add new test method following existing patterns +3. Update `main()` function to call new test +4. Update result aggregation in `benchmark-runner.sh` + +### Modifying Relay Configurations + +Each relay's Dockerfile and configuration can be customized: +- **Resource limits**: Adjust memory/CPU limits in docker-compose.yml +- **Database settings**: Modify configuration files in `configs/` +- **Network settings**: Update port mappings and health checks + +### Debugging + +```bash +# View logs for specific relay +docker-compose logs next-orly + +# Run benchmark with debug output +docker-compose up --build benchmark-runner + +# Check individual container health +docker-compose ps +``` + +## Troubleshooting + +### Common Issues + +1. **Relay fails to start**: Check logs with `docker-compose logs ` +2. **Connection refused**: Ensure relay health checks are passing +3. **Build failures**: Verify external repositories were cloned correctly +4. **Permission errors**: Ensure setup script is executable + +### Performance Issues + +- **Low throughput**: Check resource limits and concurrent worker count +- **High memory usage**: Monitor container resource consumption +- **Network bottlenecks**: Test on different host configurations + +### Reset Environment + +```bash +# Clean up everything +docker-compose down -v +docker system prune -f +rm -rf external/ data/ reports/ + +# Start fresh +./setup-external-relays.sh +docker-compose up --build +``` + +## Contributing + +To add support for new relay implementations: + +1. Create appropriate Dockerfile following existing patterns +2. Add service definition to `docker-compose.yml` +3. Update `BENCHMARK_TARGETS` environment variable +4. Test the new relay integration +5. Update documentation + +## License + +This benchmark suite is part of the next.orly.dev project and follows the same licensing terms. \ No newline at end of file diff --git a/cmd/benchmark/benchmark-runner.sh b/cmd/benchmark/benchmark-runner.sh new file mode 100644 index 0000000..4271f55 --- /dev/null +++ b/cmd/benchmark/benchmark-runner.sh @@ -0,0 +1,265 @@ +#!/bin/sh + +# Benchmark runner script for testing multiple Nostr relay implementations +# This script coordinates testing all relays and aggregates results + +set -e + +# Configuration from environment variables +BENCHMARK_EVENTS="${BENCHMARK_EVENTS:-10000}" +BENCHMARK_WORKERS="${BENCHMARK_WORKERS:-8}" +BENCHMARK_DURATION="${BENCHMARK_DURATION:-60s}" +BENCHMARK_TARGETS="${BENCHMARK_TARGETS:-next-orly:8001,khatru-sqlite:8002,khatru-badger:8003,relayer-basic:8004,strfry:8005,nostr-rs-relay:8006}" +OUTPUT_DIR="${OUTPUT_DIR:-/reports}" + +# Create output directory +mkdir -p "${OUTPUT_DIR}" + +# Generate timestamp for this benchmark run +TIMESTAMP=$(date +"%Y%m%d_%H%M%S") +RUN_DIR="${OUTPUT_DIR}/run_${TIMESTAMP}" +mkdir -p "${RUN_DIR}" + +echo "==================================================" +echo "Nostr Relay Benchmark Suite" +echo "==================================================" +echo "Timestamp: $(date)" +echo "Events per test: ${BENCHMARK_EVENTS}" +echo "Concurrent workers: ${BENCHMARK_WORKERS}" +echo "Test duration: ${BENCHMARK_DURATION}" +echo "Output directory: ${RUN_DIR}" +echo "==================================================" + +# Function to wait for relay to be ready +wait_for_relay() { + local name="$1" + local url="$2" + local max_attempts=60 + local attempt=0 + + echo "Waiting for ${name} to be ready at ${url}..." + + while [ $attempt -lt $max_attempts ]; do + if wget --quiet --tries=1 --spider --timeout=5 "http://${url}" 2>/dev/null || \ + curl -f --connect-timeout 5 --max-time 5 "http://${url}" >/dev/null 2>&1; then + echo "${name} is ready!" + return 0 + fi + + attempt=$((attempt + 1)) + echo " Attempt ${attempt}/${max_attempts}: ${name} not ready yet..." + sleep 2 + done + + echo "ERROR: ${name} failed to become ready after ${max_attempts} attempts" + return 1 +} + +# Function to run benchmark against a specific relay +run_benchmark() { + local relay_name="$1" + local relay_url="$2" + local output_file="$3" + + echo "" + echo "==================================================" + echo "Testing ${relay_name} at ws://${relay_url}" + echo "==================================================" + + # Wait for relay to be ready + if ! wait_for_relay "${relay_name}" "${relay_url}"; then + echo "ERROR: ${relay_name} is not responding, skipping..." + echo "RELAY: ${relay_name}" > "${output_file}" + echo "STATUS: FAILED - Relay not responding" >> "${output_file}" + echo "ERROR: Connection failed" >> "${output_file}" + return 1 + fi + + # Run the benchmark + echo "Running benchmark against ${relay_name}..." + + # Create temporary directory for this relay's data + TEMP_DATA_DIR="/tmp/benchmark_${relay_name}_$$" + mkdir -p "${TEMP_DATA_DIR}" + + # Run benchmark and capture both stdout and stderr + if /app/benchmark \ + -datadir="${TEMP_DATA_DIR}" \ + -events="${BENCHMARK_EVENTS}" \ + -workers="${BENCHMARK_WORKERS}" \ + -duration="${BENCHMARK_DURATION}" \ + > "${output_file}" 2>&1; then + + echo "✓ Benchmark completed successfully for ${relay_name}" + + # Add relay identification to the report + echo "" >> "${output_file}" + echo "RELAY_NAME: ${relay_name}" >> "${output_file}" + echo "RELAY_URL: ws://${relay_url}" >> "${output_file}" + echo "TEST_TIMESTAMP: $(date -Iseconds)" >> "${output_file}" + echo "BENCHMARK_CONFIG:" >> "${output_file}" + echo " Events: ${BENCHMARK_EVENTS}" >> "${output_file}" + echo " Workers: ${BENCHMARK_WORKERS}" >> "${output_file}" + echo " Duration: ${BENCHMARK_DURATION}" >> "${output_file}" + + else + echo "✗ Benchmark failed for ${relay_name}" + echo "" >> "${output_file}" + echo "RELAY_NAME: ${relay_name}" >> "${output_file}" + echo "RELAY_URL: ws://${relay_url}" >> "${output_file}" + echo "STATUS: FAILED" >> "${output_file}" + echo "TEST_TIMESTAMP: $(date -Iseconds)" >> "${output_file}" + fi + + # Clean up temporary data + rm -rf "${TEMP_DATA_DIR}" +} + +# Function to generate aggregate report +generate_aggregate_report() { + local aggregate_file="${RUN_DIR}/aggregate_report.txt" + + echo "Generating aggregate report..." + + cat > "${aggregate_file}" << EOF +================================================================ +NOSTR RELAY BENCHMARK AGGREGATE REPORT +================================================================ +Generated: $(date -Iseconds) +Benchmark Configuration: + Events per test: ${BENCHMARK_EVENTS} + Concurrent workers: ${BENCHMARK_WORKERS} + Test duration: ${BENCHMARK_DURATION} + +Relays tested: $(echo "${BENCHMARK_TARGETS}" | tr ',' '\n' | wc -l) + +================================================================ +SUMMARY BY RELAY +================================================================ + +EOF + + # Process each relay's results + echo "${BENCHMARK_TARGETS}" | tr ',' '\n' | while IFS=':' read -r relay_name relay_port; do + if [ -z "${relay_name}" ] || [ -z "${relay_port}" ]; then + continue + fi + + relay_file="${RUN_DIR}/${relay_name}_results.txt" + + echo "Relay: ${relay_name}" >> "${aggregate_file}" + echo "----------------------------------------" >> "${aggregate_file}" + + if [ -f "${relay_file}" ]; then + # Extract key metrics from the relay's report + if grep -q "STATUS: FAILED" "${relay_file}"; then + echo "Status: FAILED" >> "${aggregate_file}" + grep "ERROR:" "${relay_file}" | head -1 >> "${aggregate_file}" || echo "Error: Unknown failure" >> "${aggregate_file}" + else + echo "Status: COMPLETED" >> "${aggregate_file}" + + # Extract performance metrics + grep "Events/sec:" "${relay_file}" | head -3 >> "${aggregate_file}" || true + grep "Success Rate:" "${relay_file}" | head -3 >> "${aggregate_file}" || true + grep "Avg Latency:" "${relay_file}" | head -3 >> "${aggregate_file}" || true + grep "P95 Latency:" "${relay_file}" | head -3 >> "${aggregate_file}" || true + grep "Memory:" "${relay_file}" | head -3 >> "${aggregate_file}" || true + fi + else + echo "Status: NO RESULTS FILE" >> "${aggregate_file}" + echo "Error: Results file not found" >> "${aggregate_file}" + fi + + echo "" >> "${aggregate_file}" + done + + cat >> "${aggregate_file}" << EOF + +================================================================ +DETAILED RESULTS +================================================================ + +Individual relay reports are available in: +$(ls "${RUN_DIR}"/*_results.txt 2>/dev/null | sed 's|^| - |' || echo " No individual reports found") + +================================================================ +BENCHMARK COMPARISON TABLE +================================================================ + +EOF + + # Create a comparison table + printf "%-20s %-10s %-15s %-15s %-15s\n" "Relay" "Status" "Peak Tput/s" "Avg Latency" "Success Rate" >> "${aggregate_file}" + printf "%-20s %-10s %-15s %-15s %-15s\n" "----" "------" "-----------" "-----------" "------------" >> "${aggregate_file}" + + echo "${BENCHMARK_TARGETS}" | tr ',' '\n' | while IFS=':' read -r relay_name relay_port; do + if [ -z "${relay_name}" ] || [ -z "${relay_port}" ]; then + continue + fi + + relay_file="${RUN_DIR}/${relay_name}_results.txt" + + if [ -f "${relay_file}" ]; then + if grep -q "STATUS: FAILED" "${relay_file}"; then + printf "%-20s %-10s %-15s %-15s %-15s\n" "${relay_name}" "FAILED" "-" "-" "-" >> "${aggregate_file}" + else + # Extract metrics for the table + peak_tput=$(grep "Events/sec:" "${relay_file}" | head -1 | awk '{print $2}' || echo "-") + avg_latency=$(grep "Avg Latency:" "${relay_file}" | head -1 | awk '{print $3}' || echo "-") + success_rate=$(grep "Success Rate:" "${relay_file}" | head -1 | awk '{print $3}' || echo "-") + + printf "%-20s %-10s %-15s %-15s %-15s\n" "${relay_name}" "OK" "${peak_tput}" "${avg_latency}" "${success_rate}" >> "${aggregate_file}" + fi + else + printf "%-20s %-10s %-15s %-15s %-15s\n" "${relay_name}" "NO DATA" "-" "-" "-" >> "${aggregate_file}" + fi + done + + echo "" >> "${aggregate_file}" + echo "================================================================" >> "${aggregate_file}" + echo "End of Report" >> "${aggregate_file}" + echo "================================================================" >> "${aggregate_file}" +} + +# Main execution +echo "Starting relay benchmark suite..." + +# Parse targets and run benchmarks +echo "${BENCHMARK_TARGETS}" | tr ',' '\n' | while IFS=':' read -r relay_name relay_port; do + if [ -z "${relay_name}" ] || [ -z "${relay_port}" ]; then + echo "WARNING: Skipping invalid target: ${relay_name}:${relay_port}" + continue + fi + + relay_url="${relay_name}:${relay_port}" + output_file="${RUN_DIR}/${relay_name}_results.txt" + + run_benchmark "${relay_name}" "${relay_url}" "${output_file}" + + # Small delay between tests + sleep 5 +done + +# Generate aggregate report +generate_aggregate_report + +echo "" +echo "==================================================" +echo "Benchmark Suite Completed!" +echo "==================================================" +echo "Results directory: ${RUN_DIR}" +echo "Aggregate report: ${RUN_DIR}/aggregate_report.txt" +echo "" + +# Display summary +if [ -f "${RUN_DIR}/aggregate_report.txt" ]; then + echo "Quick Summary:" + echo "==============" + grep -A 10 "BENCHMARK COMPARISON TABLE" "${RUN_DIR}/aggregate_report.txt" | tail -n +4 +fi + +echo "" +echo "All benchmark files:" +ls -la "${RUN_DIR}/" +echo "" +echo "Benchmark suite finished at: $(date)" \ No newline at end of file diff --git a/cmd/benchmark/configs/config.toml b/cmd/benchmark/configs/config.toml new file mode 100644 index 0000000..4f0dff4 --- /dev/null +++ b/cmd/benchmark/configs/config.toml @@ -0,0 +1,36 @@ +[info] +relay_url = "ws://localhost:8080" +name = "nostr-rs-relay benchmark" +description = "A nostr-rs-relay for benchmarking" +pubkey = "" +contact = "" + +[database] +data_directory = "/data" +in_memory = false +engine = "sqlite" + +[network] +port = 8080 +address = "0.0.0.0" + +[limits] +messages_per_sec = 0 +subscriptions_per_min = 0 +max_event_bytes = 65535 +max_ws_message_bytes = 131072 +max_ws_frame_bytes = 131072 + +[authorization] +pubkey_whitelist = [] + +[verified_users] +mode = "passive" +domain_whitelist = [] +domain_blacklist = [] + +[pay_to_relay] +enabled = false + +[options] +reject_future_seconds = 30 diff --git a/cmd/benchmark/configs/strfry.conf b/cmd/benchmark/configs/strfry.conf new file mode 100644 index 0000000..5712fa3 --- /dev/null +++ b/cmd/benchmark/configs/strfry.conf @@ -0,0 +1,101 @@ +## +## Default strfry config +## + +# Directory that contains the strfry LMDB database (restart required) +db = "/data/strfry.lmdb" + +dbParams { + # Maximum number of threads/processes that can simultaneously have LMDB transactions open (restart required) + maxreaders = 256 + + # Size of mmap to use when loading LMDB (default is 1TB, which is probably reasonable) (restart required) + mapsize = 1099511627776 +} + +relay { + # Interface to listen on. Use 0.0.0.0 to listen on all interfaces (restart required) + bind = "0.0.0.0" + + # Port to open for the nostr websocket protocol (restart required) + port = 8080 + + # Set OS-limit on maximum number of open files/sockets (if 0, don't attempt to set) (restart required) + nofiles = 1000000 + + # HTTP header that contains the client's real IP, before reverse proxying (ie x-real-ip) (MUST be all lower-case) + realIpHeader = "" + + info { + # NIP-11: Name of this server. Short/descriptive (< 30 characters) + name = "strfry benchmark" + + # NIP-11: Detailed description of this server, free-form + description = "A strfry relay for benchmarking" + + # NIP-11: Administrative pubkey, for contact purposes + pubkey = "" + + # NIP-11: Alternative contact for this server + contact = "" + } + + # Maximum accepted incoming websocket frame size (should be larger than max event) (restart required) + maxWebsocketPayloadSize = 131072 + + # Websocket-level PING message frequency (should be less than any reverse proxy idle timeouts) (restart required) + autoPingSeconds = 55 + + # If TCP keep-alive should be enabled (detect dropped connections to upstream reverse proxy) (restart required) + enableTcpKeepalive = false + + # How much uninterrupted CPU time a REQ query should get during its DB scan + queryTimesliceBudgetMicroseconds = 10000 + + # Maximum records that can be returned per filter + maxFilterLimit = 500 + + # Maximum number of subscriptions (concurrent REQs) a connection can have open at any time + maxSubsPerConnection = 20 + + writePolicy { + # If non-empty, path to an executable script that implements the writePolicy plugin logic + plugin = "" + } + + compression { + # Use permessage-deflate compression if supported by client. Reduces bandwidth, but uses more CPU (restart required) + enabled = true + + # Maintain a sliding window buffer for each connection. Improves compression, but uses more memory (restart required) + slidingWindow = true + } + + logging { + # Dump all incoming messages + dumpInAll = false + + # Dump all incoming EVENT messages + dumpInEvents = false + + # Dump all incoming REQ/CLOSE messages + dumpInReqs = false + + # Log performance metrics for initial REQ database scans + dbScanPerf = false + } + + numThreads { + # Ingester threads: route incoming requests, validate events/sigs (restart required) + ingester = 3 + + # reqWorker threads: Handle initial DB scan for events (restart required) + reqWorker = 3 + + # reqMonitor threads: Handle filtering of new events (restart required) + reqMonitor = 3 + + # yesstr threads: experimental yesstr protocol (restart required) + yesstr = 1 + } +} diff --git a/cmd/benchmark/docker-compose.yml b/cmd/benchmark/docker-compose.yml new file mode 100644 index 0000000..4144c16 --- /dev/null +++ b/cmd/benchmark/docker-compose.yml @@ -0,0 +1,183 @@ +version: '3.8' + +services: + # Next.orly.dev relay (this repository) + next-orly: + build: + context: ../.. + dockerfile: cmd/benchmark/Dockerfile.next-orly + container_name: benchmark-next-orly + environment: + - DATA_DIR=/data + - LISTEN=0.0.0.0 + - PORT=8080 + - LOG_LEVEL=info + volumes: + - ./data/next-orly:/data + ports: + - "8001:8080" + networks: + - benchmark-net + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + # Khatru with SQLite + khatru-sqlite: + build: + context: ./external/khatru + dockerfile: ../../Dockerfile.khatru-sqlite + container_name: benchmark-khatru-sqlite + environment: + - DATABASE_TYPE=sqlite + - DATABASE_PATH=/data/khatru.db + - PORT=8080 + volumes: + - ./data/khatru-sqlite:/data + ports: + - "8002:8080" + networks: + - benchmark-net + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + # Khatru with Badger + khatru-badger: + build: + context: ./external/khatru + dockerfile: ../../Dockerfile.khatru-badger + container_name: benchmark-khatru-badger + environment: + - DATABASE_TYPE=badger + - DATABASE_PATH=/data/badger + - PORT=8080 + volumes: + - ./data/khatru-badger:/data + ports: + - "8003:8080" + networks: + - benchmark-net + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + # Relayer basic example + relayer-basic: + build: + context: ./external/relayer + dockerfile: ../../Dockerfile.relayer-basic + container_name: benchmark-relayer-basic + environment: + - PORT=8080 + - DATABASE_PATH=/data/relayer.db + volumes: + - ./data/relayer-basic:/data + ports: + - "8004:8080" + networks: + - benchmark-net + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + # Strfry + strfry: + build: + context: ./external/strfry + dockerfile: ../../Dockerfile.strfry + container_name: benchmark-strfry + environment: + - STRFRY_DB_PATH=/data/strfry.lmdb + - STRFRY_RELAY_PORT=8080 + volumes: + - ./data/strfry:/data + - ./configs/strfry.conf:/etc/strfry.conf + ports: + - "8005:8080" + networks: + - benchmark-net + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + # Nostr-rs-relay + nostr-rs-relay: + build: + context: ./external/nostr-rs-relay + dockerfile: ../../Dockerfile.nostr-rs-relay + container_name: benchmark-nostr-rs-relay + environment: + - RUST_LOG=info + volumes: + - ./data/nostr-rs-relay:/data + - ./configs/config.toml:/app/config.toml + ports: + - "8006:8080" + networks: + - benchmark-net + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + # Benchmark runner + benchmark-runner: + build: + context: ../.. + dockerfile: cmd/benchmark/Dockerfile.benchmark + container_name: benchmark-runner + depends_on: + next-orly: + condition: service_healthy + khatru-sqlite: + condition: service_healthy + khatru-badger: + condition: service_healthy + relayer-basic: + condition: service_healthy + strfry: + condition: service_healthy + nostr-rs-relay: + condition: service_healthy + environment: + - BENCHMARK_TARGETS=next-orly:8001,khatru-sqlite:8002,khatru-badger:8003,relayer-basic:8004,strfry:8005,nostr-rs-relay:8006 + - BENCHMARK_EVENTS=10000 + - BENCHMARK_WORKERS=8 + - BENCHMARK_DURATION=60s + volumes: + - ./reports:/reports + networks: + - benchmark-net + command: > + sh -c " + echo 'Waiting for all relays to be ready...' && + sleep 30 && + echo 'Starting benchmark tests...' && + /app/benchmark-runner --output-dir=/reports + " + +networks: + benchmark-net: + driver: bridge + +volumes: + benchmark-data: + driver: local \ No newline at end of file diff --git a/cmd/benchmark/external/khatru b/cmd/benchmark/external/khatru new file mode 160000 index 0000000..668c41b --- /dev/null +++ b/cmd/benchmark/external/khatru @@ -0,0 +1 @@ +Subproject commit 668c41b98886ceb1980a2ead97e7e2ba0f5f0485 diff --git a/cmd/benchmark/main.go b/cmd/benchmark/main.go new file mode 100644 index 0000000..01c8596 --- /dev/null +++ b/cmd/benchmark/main.go @@ -0,0 +1,573 @@ +package main + +import ( + "context" + "crypto/rand" + "flag" + "fmt" + "log" + "os" + "path/filepath" + "runtime" + "strings" + "sync" + "time" + + "next.orly.dev/pkg/database" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" +) + +type BenchmarkConfig struct { + DataDir string + NumEvents int + ConcurrentWorkers int + TestDuration time.Duration + BurstPattern bool + ReportInterval time.Duration +} + +type BenchmarkResult struct { + TestName string + Duration time.Duration + TotalEvents int + EventsPerSecond float64 + AvgLatency time.Duration + P95Latency time.Duration + P99Latency time.Duration + SuccessRate float64 + ConcurrentWorkers int + MemoryUsed uint64 + Errors []string +} + +type Benchmark struct { + config *BenchmarkConfig + db *database.D + results []*BenchmarkResult + mu sync.RWMutex +} + +func main() { + config := parseFlags() + + fmt.Printf("Starting Nostr Relay Benchmark\n") + fmt.Printf("Data Directory: %s\n", config.DataDir) + fmt.Printf( + "Events: %d, Workers: %d, Duration: %v\n", + config.NumEvents, config.ConcurrentWorkers, config.TestDuration, + ) + + benchmark := NewBenchmark(config) + defer benchmark.Close() + + // Run benchmark tests + benchmark.RunPeakThroughputTest() + benchmark.RunBurstPatternTest() + benchmark.RunMixedReadWriteTest() + + // Generate report + benchmark.GenerateReport() +} + +func parseFlags() *BenchmarkConfig { + config := &BenchmarkConfig{} + + flag.StringVar( + &config.DataDir, "datadir", "/tmp/benchmark_db", "Database directory", + ) + flag.IntVar( + &config.NumEvents, "events", 10000, "Number of events to generate", + ) + flag.IntVar( + &config.ConcurrentWorkers, "workers", runtime.NumCPU(), + "Number of concurrent workers", + ) + flag.DurationVar( + &config.TestDuration, "duration", 60*time.Second, "Test duration", + ) + flag.BoolVar( + &config.BurstPattern, "burst", true, "Enable burst pattern testing", + ) + flag.DurationVar( + &config.ReportInterval, "report-interval", 10*time.Second, + "Report interval", + ) + + flag.Parse() + return config +} + +func NewBenchmark(config *BenchmarkConfig) *Benchmark { + // Clean up existing data directory + os.RemoveAll(config.DataDir) + + ctx := context.Background() + cancel := func() {} + + db, err := database.New(ctx, cancel, config.DataDir, "info") + if err != nil { + log.Fatalf("Failed to create database: %v", err) + } + + return &Benchmark{ + config: config, + db: db, + results: make([]*BenchmarkResult, 0), + } +} + +func (b *Benchmark) Close() { + if b.db != nil { + b.db.Close() + } +} + +func (b *Benchmark) RunPeakThroughputTest() { + fmt.Println("\n=== Peak Throughput Test ===") + + start := time.Now() + var wg sync.WaitGroup + var totalEvents int64 + var errors []error + var latencies []time.Duration + var mu sync.Mutex + + events := b.generateEvents(b.config.NumEvents) + eventChan := make(chan *event.E, len(events)) + + // Fill event channel + for _, ev := range events { + eventChan <- ev + } + close(eventChan) + + // Start workers + for i := 0; i < b.config.ConcurrentWorkers; i++ { + wg.Add(1) + go func(workerID int) { + defer wg.Done() + + ctx := context.Background() + for ev := range eventChan { + eventStart := time.Now() + + _, _, err := b.db.SaveEvent(ctx, ev) + latency := time.Since(eventStart) + + mu.Lock() + if err != nil { + errors = append(errors, err) + } else { + totalEvents++ + latencies = append(latencies, latency) + } + mu.Unlock() + } + }(i) + } + + wg.Wait() + duration := time.Since(start) + + // Calculate metrics + result := &BenchmarkResult{ + TestName: "Peak Throughput", + Duration: duration, + TotalEvents: int(totalEvents), + EventsPerSecond: float64(totalEvents) / duration.Seconds(), + ConcurrentWorkers: b.config.ConcurrentWorkers, + MemoryUsed: getMemUsage(), + } + + if len(latencies) > 0 { + result.AvgLatency = calculateAvgLatency(latencies) + result.P95Latency = calculatePercentileLatency(latencies, 0.95) + result.P99Latency = calculatePercentileLatency(latencies, 0.99) + } + + result.SuccessRate = float64(totalEvents) / float64(b.config.NumEvents) * 100 + + for _, err := range errors { + result.Errors = append(result.Errors, err.Error()) + } + + b.mu.Lock() + b.results = append(b.results, result) + b.mu.Unlock() + + fmt.Printf( + "Events saved: %d/%d (%.1f%%)\n", totalEvents, b.config.NumEvents, + result.SuccessRate, + ) + fmt.Printf("Duration: %v\n", duration) + fmt.Printf("Events/sec: %.2f\n", result.EventsPerSecond) + fmt.Printf("Avg latency: %v\n", result.AvgLatency) + fmt.Printf("P95 latency: %v\n", result.P95Latency) + fmt.Printf("P99 latency: %v\n", result.P99Latency) +} + +func (b *Benchmark) RunBurstPatternTest() { + fmt.Println("\n=== Burst Pattern Test ===") + + start := time.Now() + var totalEvents int64 + var errors []error + var latencies []time.Duration + var mu sync.Mutex + + // Generate events for burst pattern + events := b.generateEvents(b.config.NumEvents) + + // Simulate burst pattern: high activity periods followed by quiet periods + burstSize := b.config.NumEvents / 10 // 10% of events in each burst + quietPeriod := 500 * time.Millisecond + burstPeriod := 100 * time.Millisecond + + ctx := context.Background() + eventIndex := 0 + + for eventIndex < len(events) && time.Since(start) < b.config.TestDuration { + // Burst period - send events rapidly + burstStart := time.Now() + var wg sync.WaitGroup + + for i := 0; i < burstSize && eventIndex < len(events); i++ { + wg.Add(1) + go func(ev *event.E) { + defer wg.Done() + + eventStart := time.Now() + _, _, err := b.db.SaveEvent(ctx, ev) + latency := time.Since(eventStart) + + mu.Lock() + if err != nil { + errors = append(errors, err) + } else { + totalEvents++ + latencies = append(latencies, latency) + } + mu.Unlock() + }(events[eventIndex]) + + eventIndex++ + time.Sleep(burstPeriod / time.Duration(burstSize)) + } + + wg.Wait() + fmt.Printf( + "Burst completed: %d events in %v\n", burstSize, + time.Since(burstStart), + ) + + // Quiet period + time.Sleep(quietPeriod) + } + + duration := time.Since(start) + + // Calculate metrics + result := &BenchmarkResult{ + TestName: "Burst Pattern", + Duration: duration, + TotalEvents: int(totalEvents), + EventsPerSecond: float64(totalEvents) / duration.Seconds(), + ConcurrentWorkers: b.config.ConcurrentWorkers, + MemoryUsed: getMemUsage(), + } + + if len(latencies) > 0 { + result.AvgLatency = calculateAvgLatency(latencies) + result.P95Latency = calculatePercentileLatency(latencies, 0.95) + result.P99Latency = calculatePercentileLatency(latencies, 0.99) + } + + result.SuccessRate = float64(totalEvents) / float64(eventIndex) * 100 + + for _, err := range errors { + result.Errors = append(result.Errors, err.Error()) + } + + b.mu.Lock() + b.results = append(b.results, result) + b.mu.Unlock() + + fmt.Printf("Burst test completed: %d events in %v\n", totalEvents, duration) + fmt.Printf("Events/sec: %.2f\n", result.EventsPerSecond) +} + +func (b *Benchmark) RunMixedReadWriteTest() { + fmt.Println("\n=== Mixed Read/Write Test ===") + + start := time.Now() + var totalWrites, totalReads int64 + var writeLatencies, readLatencies []time.Duration + var errors []error + var mu sync.Mutex + + // Pre-populate with some events for reading + seedEvents := b.generateEvents(1000) + ctx := context.Background() + + fmt.Println("Pre-populating database for read tests...") + for _, ev := range seedEvents { + b.db.SaveEvent(ctx, ev) + } + + events := b.generateEvents(b.config.NumEvents) + var wg sync.WaitGroup + + // Start mixed read/write workers + for i := 0; i < b.config.ConcurrentWorkers; i++ { + wg.Add(1) + go func(workerID int) { + defer wg.Done() + + eventIndex := workerID + for time.Since(start) < b.config.TestDuration && eventIndex < len(events) { + // Alternate between write and read operations + if eventIndex%2 == 0 { + // Write operation + writeStart := time.Now() + _, _, err := b.db.SaveEvent(ctx, events[eventIndex]) + writeLatency := time.Since(writeStart) + + mu.Lock() + if err != nil { + errors = append(errors, err) + } else { + totalWrites++ + writeLatencies = append(writeLatencies, writeLatency) + } + mu.Unlock() + } else { + // Read operation + readStart := time.Now() + f := filter.New() + f.Kinds = kind.NewS(kind.TextNote) + limit := uint(10) + f.Limit = &limit + _, err := b.db.GetSerialsFromFilter(f) + readLatency := time.Since(readStart) + + mu.Lock() + if err != nil { + errors = append(errors, err) + } else { + totalReads++ + readLatencies = append(readLatencies, readLatency) + } + mu.Unlock() + } + + eventIndex += b.config.ConcurrentWorkers + time.Sleep(10 * time.Millisecond) // Small delay between operations + } + }(i) + } + + wg.Wait() + duration := time.Since(start) + + // Calculate metrics + result := &BenchmarkResult{ + TestName: "Mixed Read/Write", + Duration: duration, + TotalEvents: int(totalWrites + totalReads), + EventsPerSecond: float64(totalWrites+totalReads) / duration.Seconds(), + ConcurrentWorkers: b.config.ConcurrentWorkers, + MemoryUsed: getMemUsage(), + } + + // Calculate combined latencies for overall metrics + allLatencies := append(writeLatencies, readLatencies...) + if len(allLatencies) > 0 { + result.AvgLatency = calculateAvgLatency(allLatencies) + result.P95Latency = calculatePercentileLatency(allLatencies, 0.95) + result.P99Latency = calculatePercentileLatency(allLatencies, 0.99) + } + + result.SuccessRate = float64(totalWrites+totalReads) / float64(len(events)) * 100 + + for _, err := range errors { + result.Errors = append(result.Errors, err.Error()) + } + + b.mu.Lock() + b.results = append(b.results, result) + b.mu.Unlock() + + fmt.Printf( + "Mixed test completed: %d writes, %d reads in %v\n", totalWrites, + totalReads, duration, + ) + fmt.Printf("Combined ops/sec: %.2f\n", result.EventsPerSecond) +} + +func (b *Benchmark) generateEvents(count int) []*event.E { + events := make([]*event.E, count) + now := timestamp.Now() + + for i := 0; i < count; i++ { + ev := event.New() + + // Generate random 32-byte ID + ev.ID = make([]byte, 32) + rand.Read(ev.ID) + + // Generate random 32-byte pubkey + ev.Pubkey = make([]byte, 32) + rand.Read(ev.Pubkey) + + ev.CreatedAt = now.I64() + ev.Kind = kind.TextNote.K + ev.Content = []byte(fmt.Sprintf( + "This is test event number %d with some content", i, + )) + + // Create tags using NewFromBytesSlice + ev.Tags = tag.NewS( + tag.NewFromBytesSlice([]byte("t"), []byte("benchmark")), + tag.NewFromBytesSlice( + []byte("e"), []byte(fmt.Sprintf("ref_%d", i%50)), + ), + ) + + events[i] = ev + } + + return events +} + +func (b *Benchmark) GenerateReport() { + fmt.Println("\n" + strings.Repeat("=", 80)) + fmt.Println("BENCHMARK REPORT") + fmt.Println(strings.Repeat("=", 80)) + + b.mu.RLock() + defer b.mu.RUnlock() + + for _, result := range b.results { + fmt.Printf("\nTest: %s\n", result.TestName) + fmt.Printf("Duration: %v\n", result.Duration) + fmt.Printf("Total Events: %d\n", result.TotalEvents) + fmt.Printf("Events/sec: %.2f\n", result.EventsPerSecond) + fmt.Printf("Success Rate: %.1f%%\n", result.SuccessRate) + fmt.Printf("Concurrent Workers: %d\n", result.ConcurrentWorkers) + fmt.Printf("Memory Used: %d MB\n", result.MemoryUsed/(1024*1024)) + fmt.Printf("Avg Latency: %v\n", result.AvgLatency) + fmt.Printf("P95 Latency: %v\n", result.P95Latency) + fmt.Printf("P99 Latency: %v\n", result.P99Latency) + + if len(result.Errors) > 0 { + fmt.Printf("Errors (%d):\n", len(result.Errors)) + for i, err := range result.Errors { + if i < 5 { // Show first 5 errors + fmt.Printf(" - %s\n", err) + } + } + if len(result.Errors) > 5 { + fmt.Printf(" ... and %d more errors\n", len(result.Errors)-5) + } + } + fmt.Println(strings.Repeat("-", 40)) + } + + // Save report to file + reportPath := filepath.Join(b.config.DataDir, "benchmark_report.txt") + b.saveReportToFile(reportPath) + fmt.Printf("\nReport saved to: %s\n", reportPath) +} + +func (b *Benchmark) saveReportToFile(path string) error { + file, err := os.Create(path) + if err != nil { + return err + } + defer file.Close() + + file.WriteString("NOSTR RELAY BENCHMARK REPORT\n") + file.WriteString("============================\n\n") + file.WriteString( + fmt.Sprintf( + "Generated: %s\n", time.Now().Format(time.RFC3339), + ), + ) + file.WriteString(fmt.Sprintf("Relay: next.orly.dev\n")) + file.WriteString(fmt.Sprintf("Database: BadgerDB\n")) + file.WriteString(fmt.Sprintf("Workers: %d\n", b.config.ConcurrentWorkers)) + file.WriteString( + fmt.Sprintf( + "Test Duration: %v\n\n", b.config.TestDuration, + ), + ) + + b.mu.RLock() + defer b.mu.RUnlock() + + for _, result := range b.results { + file.WriteString(fmt.Sprintf("Test: %s\n", result.TestName)) + file.WriteString(fmt.Sprintf("Duration: %v\n", result.Duration)) + file.WriteString(fmt.Sprintf("Events: %d\n", result.TotalEvents)) + file.WriteString( + fmt.Sprintf( + "Events/sec: %.2f\n", result.EventsPerSecond, + ), + ) + file.WriteString( + fmt.Sprintf( + "Success Rate: %.1f%%\n", result.SuccessRate, + ), + ) + file.WriteString(fmt.Sprintf("Avg Latency: %v\n", result.AvgLatency)) + file.WriteString(fmt.Sprintf("P95 Latency: %v\n", result.P95Latency)) + file.WriteString(fmt.Sprintf("P99 Latency: %v\n", result.P99Latency)) + file.WriteString( + fmt.Sprintf( + "Memory: %d MB\n", result.MemoryUsed/(1024*1024), + ), + ) + file.WriteString("\n") + } + + return nil +} + +// Helper functions + +func calculateAvgLatency(latencies []time.Duration) time.Duration { + if len(latencies) == 0 { + return 0 + } + + var total time.Duration + for _, l := range latencies { + total += l + } + return total / time.Duration(len(latencies)) +} + +func calculatePercentileLatency( + latencies []time.Duration, percentile float64, +) time.Duration { + if len(latencies) == 0 { + return 0 + } + + // Simple percentile calculation - in production would sort first + index := int(float64(len(latencies)) * percentile) + if index >= len(latencies) { + index = len(latencies) - 1 + } + return latencies[index] +} + +func getMemUsage() uint64 { + var m runtime.MemStats + runtime.ReadMemStats(&m) + return m.Alloc +} diff --git a/cmd/benchmark/setup-external-relays.sh b/cmd/benchmark/setup-external-relays.sh new file mode 100755 index 0000000..02b7119 --- /dev/null +++ b/cmd/benchmark/setup-external-relays.sh @@ -0,0 +1,368 @@ +#!/bin/bash + +# Setup script for downloading and configuring external relay repositories +# for benchmarking + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +EXTERNAL_DIR="${SCRIPT_DIR}/external" + +echo "Setting up external relay repositories for benchmarking..." + +# Create external directory +mkdir -p "${EXTERNAL_DIR}" + +# Function to clone or update repository +clone_or_update() { + local repo_url="$1" + local repo_dir="$2" + local repo_name="$3" + + echo "Setting up ${repo_name}..." + + if [ -d "${repo_dir}" ]; then + echo " ${repo_name} already exists, updating..." + cd "${repo_dir}" + git pull origin main 2>/dev/null || git pull origin master 2>/dev/null || true + cd - > /dev/null + else + echo " Cloning ${repo_name}..." + git clone "${repo_url}" "${repo_dir}" + fi +} + +# Clone khatru +clone_or_update "https://github.com/fiatjaf/khatru.git" "${EXTERNAL_DIR}/khatru" "Khatru" + +# Clone relayer +clone_or_update "https://github.com/fiatjaf/relayer.git" "${EXTERNAL_DIR}/relayer" "Relayer" + +# Clone strfry +clone_or_update "https://github.com/hoytech/strfry.git" "${EXTERNAL_DIR}/strfry" "Strfry" + +# Clone nostr-rs-relay +clone_or_update "https://git.sr.ht/~gheartsfield/nostr-rs-relay" "${EXTERNAL_DIR}/nostr-rs-relay" "Nostr-rs-relay" + +echo "Creating Dockerfiles for external relays..." + +# Create Dockerfile for Khatru SQLite +cat > "${SCRIPT_DIR}/Dockerfile.khatru-sqlite" << 'EOF' +FROM golang:1.25-alpine AS builder + +RUN apk add --no-cache git ca-certificates sqlite-dev gcc musl-dev + +WORKDIR /build +COPY . . + +# Build the basic-sqlite example +RUN cd examples/basic-sqlite && \ + go mod tidy && \ + CGO_ENABLED=1 go build -o khatru-sqlite . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates sqlite wget +WORKDIR /app +COPY --from=builder /build/examples/basic-sqlite/khatru-sqlite /app/ +RUN mkdir -p /data +EXPOSE 8080 +ENV DATABASE_PATH=/data/khatru.db +ENV PORT=8080 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 +CMD ["/app/khatru-sqlite"] +EOF + +# Create Dockerfile for Khatru Badger +cat > "${SCRIPT_DIR}/Dockerfile.khatru-badger" << 'EOF' +FROM golang:1.25-alpine AS builder + +RUN apk add --no-cache git ca-certificates + +WORKDIR /build +COPY . . + +# Build the basic-badger example +RUN cd examples/basic-badger && \ + go mod tidy && \ + CGO_ENABLED=0 go build -o khatru-badger . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates wget +WORKDIR /app +COPY --from=builder /build/examples/basic-badger/khatru-badger /app/ +RUN mkdir -p /data +EXPOSE 8080 +ENV DATABASE_PATH=/data/badger +ENV PORT=8080 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 +CMD ["/app/khatru-badger"] +EOF + +# Create Dockerfile for Relayer basic example +cat > "${SCRIPT_DIR}/Dockerfile.relayer-basic" << 'EOF' +FROM golang:1.25-alpine AS builder + +RUN apk add --no-cache git ca-certificates sqlite-dev gcc musl-dev + +WORKDIR /build +COPY . . + +# Build the basic example +RUN cd examples/basic && \ + go mod tidy && \ + CGO_ENABLED=1 go build -o relayer-basic . + +FROM alpine:latest +RUN apk --no-cache add ca-certificates sqlite wget +WORKDIR /app +COPY --from=builder /build/examples/basic/relayer-basic /app/ +RUN mkdir -p /data +EXPOSE 8080 +ENV DATABASE_PATH=/data/relayer.db +ENV PORT=8080 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 +CMD ["/app/relayer-basic"] +EOF + +# Create Dockerfile for Strfry +cat > "${SCRIPT_DIR}/Dockerfile.strfry" << 'EOF' +FROM ubuntu:22.04 AS builder + +ENV DEBIAN_FRONTEND=noninteractive + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + git \ + build-essential \ + liblmdb-dev \ + libsecp256k1-dev \ + pkg-config \ + libtool \ + autoconf \ + automake \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /build +COPY . . + +# Build strfry +RUN make setup-golpe && \ + make -j$(nproc) + +FROM ubuntu:22.04 +RUN apt-get update && apt-get install -y \ + liblmdb0 \ + libsecp256k1-0 \ + curl \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY --from=builder /build/strfry /app/ +RUN mkdir -p /data + +EXPOSE 8080 +ENV STRFRY_DB_PATH=/data/strfry.lmdb +ENV STRFRY_RELAY_PORT=8080 + +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8080 || exit 1 + +CMD ["/app/strfry", "relay"] +EOF + +# Create Dockerfile for nostr-rs-relay +cat > "${SCRIPT_DIR}/Dockerfile.nostr-rs-relay" << 'EOF' +FROM rust:1.70-alpine AS builder + +RUN apk add --no-cache musl-dev sqlite-dev + +WORKDIR /build +COPY . . + +# Build the relay +RUN cargo build --release + +FROM alpine:latest +RUN apk --no-cache add ca-certificates sqlite wget +WORKDIR /app +COPY --from=builder /build/target/release/nostr-rs-relay /app/ +RUN mkdir -p /data + +EXPOSE 8080 +ENV RUST_LOG=info + +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost:8080 || exit 1 + +CMD ["/app/nostr-rs-relay"] +EOF + +echo "Creating configuration files..." + +# Create configs directory +mkdir -p "${SCRIPT_DIR}/configs" + +# Create strfry configuration +cat > "${SCRIPT_DIR}/configs/strfry.conf" << 'EOF' +## +## Default strfry config +## + +# Directory that contains the strfry LMDB database (restart required) +db = "/data/strfry.lmdb" + +dbParams { + # Maximum number of threads/processes that can simultaneously have LMDB transactions open (restart required) + maxreaders = 256 + + # Size of mmap to use when loading LMDB (default is 1TB, which is probably reasonable) (restart required) + mapsize = 1099511627776 +} + +relay { + # Interface to listen on. Use 0.0.0.0 to listen on all interfaces (restart required) + bind = "0.0.0.0" + + # Port to open for the nostr websocket protocol (restart required) + port = 8080 + + # Set OS-limit on maximum number of open files/sockets (if 0, don't attempt to set) (restart required) + nofiles = 1000000 + + # HTTP header that contains the client's real IP, before reverse proxying (ie x-real-ip) (MUST be all lower-case) + realIpHeader = "" + + info { + # NIP-11: Name of this server. Short/descriptive (< 30 characters) + name = "strfry benchmark" + + # NIP-11: Detailed description of this server, free-form + description = "A strfry relay for benchmarking" + + # NIP-11: Administrative pubkey, for contact purposes + pubkey = "" + + # NIP-11: Alternative contact for this server + contact = "" + } + + # Maximum accepted incoming websocket frame size (should be larger than max event) (restart required) + maxWebsocketPayloadSize = 131072 + + # Websocket-level PING message frequency (should be less than any reverse proxy idle timeouts) (restart required) + autoPingSeconds = 55 + + # If TCP keep-alive should be enabled (detect dropped connections to upstream reverse proxy) (restart required) + enableTcpKeepalive = false + + # How much uninterrupted CPU time a REQ query should get during its DB scan + queryTimesliceBudgetMicroseconds = 10000 + + # Maximum records that can be returned per filter + maxFilterLimit = 500 + + # Maximum number of subscriptions (concurrent REQs) a connection can have open at any time + maxSubsPerConnection = 20 + + writePolicy { + # If non-empty, path to an executable script that implements the writePolicy plugin logic + plugin = "" + } + + compression { + # Use permessage-deflate compression if supported by client. Reduces bandwidth, but uses more CPU (restart required) + enabled = true + + # Maintain a sliding window buffer for each connection. Improves compression, but uses more memory (restart required) + slidingWindow = true + } + + logging { + # Dump all incoming messages + dumpInAll = false + + # Dump all incoming EVENT messages + dumpInEvents = false + + # Dump all incoming REQ/CLOSE messages + dumpInReqs = false + + # Log performance metrics for initial REQ database scans + dbScanPerf = false + } + + numThreads { + # Ingester threads: route incoming requests, validate events/sigs (restart required) + ingester = 3 + + # reqWorker threads: Handle initial DB scan for events (restart required) + reqWorker = 3 + + # reqMonitor threads: Handle filtering of new events (restart required) + reqMonitor = 3 + + # yesstr threads: experimental yesstr protocol (restart required) + yesstr = 1 + } +} +EOF + +# Create nostr-rs-relay configuration +cat > "${SCRIPT_DIR}/configs/config.toml" << 'EOF' +[info] +relay_url = "ws://localhost:8080" +name = "nostr-rs-relay benchmark" +description = "A nostr-rs-relay for benchmarking" +pubkey = "" +contact = "" + +[database] +data_directory = "/data" +in_memory = false +engine = "sqlite" + +[network] +port = 8080 +address = "0.0.0.0" + +[limits] +messages_per_sec = 0 +subscriptions_per_min = 0 +max_event_bytes = 65535 +max_ws_message_bytes = 131072 +max_ws_frame_bytes = 131072 + +[authorization] +pubkey_whitelist = [] + +[verified_users] +mode = "passive" +domain_whitelist = [] +domain_blacklist = [] + +[pay_to_relay] +enabled = false + +[options] +reject_future_seconds = 30 +EOF + +echo "Creating data directories..." +mkdir -p "${SCRIPT_DIR}/data"/{next-orly,khatru-sqlite,khatru-badger,relayer-basic,strfry,nostr-rs-relay} +mkdir -p "${SCRIPT_DIR}/reports" + +echo "Setup complete!" +echo "" +echo "External relay repositories have been cloned to: ${EXTERNAL_DIR}" +echo "Dockerfiles have been created for all relay implementations" +echo "Configuration files have been created in: ${SCRIPT_DIR}/configs" +echo "Data directories have been created in: ${SCRIPT_DIR}/data" +echo "" +echo "To run the benchmark:" +echo " cd ${SCRIPT_DIR}" +echo " docker-compose up --build" +echo "" +echo "Reports will be generated in: ${SCRIPT_DIR}/reports" \ No newline at end of file diff --git a/cmd/convert/convert.go b/cmd/convert/convert.go index 984fdd2..bf0d8e5 100644 --- a/cmd/convert/convert.go +++ b/cmd/convert/convert.go @@ -6,10 +6,10 @@ import ( "os" "strings" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" - b32 "encoders.orly/bech32encoding" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + b32 "next.orly.dev/pkg/encoders/bech32encoding" + "next.orly.dev/pkg/encoders/hex" ) func usage() { diff --git a/go.mod b/go.mod index b034933..4fe6ef6 100644 --- a/go.mod +++ b/go.mod @@ -3,24 +3,29 @@ module next.orly.dev go 1.25.0 require ( - acl.orly v0.0.0-00010101000000-000000000000 - crypto.orly v0.0.0-00010101000000-000000000000 - database.orly v0.0.0-00010101000000-000000000000 - encoders.orly v0.0.0-00010101000000-000000000000 github.com/adrg/xdg v0.5.3 github.com/coder/websocket v1.8.13 + github.com/davecgh/go-spew v1.1.1 github.com/dgraph-io/badger/v4 v4.8.0 + github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 + github.com/klauspost/cpuid/v2 v2.3.0 github.com/pkg/profile v1.7.0 + github.com/puzpuzpuz/xsync/v3 v3.5.1 + github.com/stretchr/testify v1.10.0 + github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b go-simpler.org/env v0.12.0 - interfaces.orly v0.0.0-00010101000000-000000000000 + go.uber.org/atomic v1.11.0 + golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b + golang.org/x/lint v0.0.0-20241112194109-818c5a804067 + golang.org/x/net v0.43.0 + honnef.co/go/tools v0.6.1 lol.mleku.dev v1.0.2 - protocol.orly v0.0.0-00010101000000-000000000000 - utils.orly v0.0.0-00010101000000-000000000000 + lukechampine.com/frand v1.5.1 ) require ( + github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.18.0 // indirect @@ -29,32 +34,20 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/google/flatbuffers v25.2.10+incompatible // indirect github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect - github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/klauspost/compress v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/templexxx/cpu v0.0.1 // indirect - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel v1.37.0 // indirect go.opentelemetry.io/otel/metric v1.37.0 // indirect go.opentelemetry.io/otel/trace v1.37.0 // indirect - go.uber.org/atomic v1.11.0 // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect - golang.org/x/net v0.41.0 // indirect + golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect + golang.org/x/mod v0.27.0 // indirect + golang.org/x/sync v0.16.0 // indirect golang.org/x/sys v0.35.0 // indirect + golang.org/x/tools v0.36.0 // indirect google.golang.org/protobuf v1.36.6 // indirect - lukechampine.com/frand v1.5.1 // indirect -) - -replace ( - acl.orly => ./pkg/acl - crypto.orly => ./pkg/crypto - database.orly => ./pkg/database - encoders.orly => ./pkg/encoders - interfaces.orly => ./pkg/interfaces - next.orly.dev => ../../ - protocol.orly => ./pkg/protocol - utils.orly => ./pkg/utils + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e87b3e6..f3ef0c6 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -40,6 +42,10 @@ github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zt github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -48,12 +54,16 @@ github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg= +github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= @@ -70,20 +80,47 @@ go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mx go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= -golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= +golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ= +golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/lint v0.0.0-20241112194109-818c5a804067 h1:adDmSQyFTCiv19j015EGKJBoaa7ElV0Q1Wovb/4G7NA= +golang.org/x/lint v0.0.0-20241112194109-818c5a804067/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= +golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= +golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= +golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI= +honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4= lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= diff --git a/main.go b/main.go index f7f6183..164e109 100644 --- a/main.go +++ b/main.go @@ -6,12 +6,12 @@ import ( "os" "os/signal" - acl "acl.orly" - database "database.orly" "lol.mleku.dev/chk" "lol.mleku.dev/log" "next.orly.dev/app" "next.orly.dev/app/config" + acl "next.orly.dev/pkg/acl" + database "next.orly.dev/pkg/database" "next.orly.dev/pkg/version" ) diff --git a/pkg/acl/acl.go b/pkg/acl/acl.go index 4bae0db..0082c28 100644 --- a/pkg/acl/acl.go +++ b/pkg/acl/acl.go @@ -1,8 +1,8 @@ package acl import ( - "interfaces.orly/acl" - "utils.orly/atomic" + "next.orly.dev/pkg/interfaces/acl" + "next.orly.dev/pkg/utils/atomic" ) var Registry = &S{} diff --git a/pkg/acl/follows.go b/pkg/acl/follows.go index b8e9f70..1395a96 100644 --- a/pkg/acl/follows.go +++ b/pkg/acl/follows.go @@ -7,26 +7,26 @@ import ( "sync" "time" - database "database.orly" - "database.orly/indexes/types" - "encoders.orly/bech32encoding" - "encoders.orly/envelopes" - "encoders.orly/envelopes/eoseenvelope" - "encoders.orly/envelopes/eventenvelope" - "encoders.orly/envelopes/reqenvelope" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" "github.com/coder/websocket" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" "next.orly.dev/app/config" - utils "utils.orly" - "utils.orly/normalize" - "utils.orly/values" + database "next.orly.dev/pkg/database" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/bech32encoding" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/envelopes/eoseenvelope" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/envelopes/reqenvelope" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + utils "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/normalize" + "next.orly.dev/pkg/utils/values" ) type Follows struct { diff --git a/pkg/acl/go.mod b/pkg/acl/go.mod deleted file mode 100644 index b92ecbc..0000000 --- a/pkg/acl/go.mod +++ /dev/null @@ -1,54 +0,0 @@ -module acl.orly - -go 1.25.0 - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) - -require ( - database.orly v0.0.0-00010101000000-000000000000 - encoders.orly v0.0.0-00010101000000-000000000000 - interfaces.orly v0.0.0-00010101000000-000000000000 - lol.mleku.dev v1.0.2 - next.orly.dev v0.0.0-00010101000000-000000000000 - utils.orly v0.0.0-00010101000000-000000000000 -) - -require ( - crypto.orly v0.0.0-00010101000000-000000000000 // indirect - github.com/adrg/xdg v0.5.3 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/badger/v4 v4.8.0 // indirect - github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect - github.com/dustin/go-humanize v1.0.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/go-logr/logr v1.4.3 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/google/flatbuffers v25.2.10+incompatible // indirect - github.com/klauspost/compress v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/templexxx/cpu v0.0.1 // indirect - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b // indirect - go-simpler.org/env v0.12.0 // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel v1.37.0 // indirect - go.opentelemetry.io/otel/metric v1.37.0 // indirect - go.opentelemetry.io/otel/trace v1.37.0 // indirect - go.uber.org/atomic v1.11.0 // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect - golang.org/x/net v0.41.0 // indirect - golang.org/x/sys v0.35.0 // indirect - google.golang.org/protobuf v1.36.6 // indirect - lukechampine.com/frand v1.5.1 // indirect -) diff --git a/pkg/acl/go.sum b/pkg/acl/go.sum deleted file mode 100644 index 9d8dce4..0000000 --- a/pkg/acl/go.sum +++ /dev/null @@ -1,68 +0,0 @@ -github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= -github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs= -github.com/dgraph-io/badger/v4 v4.8.0/go.mod h1:U6on6e8k/RTbUWxqKR0MvugJuVmkxSNc79ap4917h4w= -github.com/dgraph-io/ristretto/v2 v2.2.0 h1:bkY3XzJcXoMuELV8F+vS8kzNgicwQFAaGINAEJdWGOM= -github.com/dgraph-io/ristretto/v2 v2.2.0/go.mod h1:RZrm63UmcBAaYWC1DotLYBmTvgkrs0+XhBd7Npn7/zI= -github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38= -github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q= -github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b/go.mod h1:7rwmCH0wC2fQvNEvPZ3sKXukhyCTyiaZ5VTZMQYpZKQ= -go-simpler.org/env v0.12.0 h1:kt/lBts0J1kjWJAnB740goNdvwNxt5emhYngL0Fzufs= -go-simpler.org/env v0.12.0/go.mod h1:cc/5Md9JCUM7LVLtN0HYjPTDcI3Q8TDaPlNTAlDU+WI= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= -golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= -google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= -lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= -lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= diff --git a/pkg/crypto/ec/base58/base58_test.go b/pkg/crypto/ec/base58/base58_test.go index 8206cb7..f7ad243 100644 --- a/pkg/crypto/ec/base58/base58_test.go +++ b/pkg/crypto/ec/base58/base58_test.go @@ -8,8 +8,8 @@ import ( "encoding/hex" "testing" - "crypto.orly/ec/base58" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/base58" + "next.orly.dev/pkg/utils" ) var stringTests = []struct { diff --git a/pkg/crypto/ec/base58/base58bench_test.go b/pkg/crypto/ec/base58/base58bench_test.go index e93e129..1240fba 100644 --- a/pkg/crypto/ec/base58/base58bench_test.go +++ b/pkg/crypto/ec/base58/base58bench_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "crypto.orly/ec/base58" + "next.orly.dev/pkg/crypto/ec/base58" ) var ( diff --git a/pkg/crypto/ec/base58/base58check.go b/pkg/crypto/ec/base58/base58check.go index 1b5162a..8d8b3d6 100644 --- a/pkg/crypto/ec/base58/base58check.go +++ b/pkg/crypto/ec/base58/base58check.go @@ -7,7 +7,7 @@ package base58 import ( "errors" - "crypto.orly/sha256" + "next.orly.dev/pkg/crypto/sha256" ) // ErrChecksum indicates that the checksum of a check-encoded string does not verify against diff --git a/pkg/crypto/ec/base58/base58check_test.go b/pkg/crypto/ec/base58/base58check_test.go index 63682a7..8f894d1 100644 --- a/pkg/crypto/ec/base58/base58check_test.go +++ b/pkg/crypto/ec/base58/base58check_test.go @@ -7,7 +7,7 @@ package base58_test import ( "testing" - "crypto.orly/ec/base58" + "next.orly.dev/pkg/crypto/ec/base58" ) var checkEncodingStringTests = []struct { diff --git a/pkg/crypto/ec/base58/example_test.go b/pkg/crypto/ec/base58/example_test.go index 7a93c82..8646c20 100644 --- a/pkg/crypto/ec/base58/example_test.go +++ b/pkg/crypto/ec/base58/example_test.go @@ -7,7 +7,7 @@ package base58_test import ( "fmt" - "crypto.orly/ec/base58" + "next.orly.dev/pkg/crypto/ec/base58" ) // This example demonstrates how to decode modified base58 encoded data. diff --git a/pkg/crypto/ec/bech32/bech32_test.go b/pkg/crypto/ec/bech32/bech32_test.go index d590631..347fd0b 100644 --- a/pkg/crypto/ec/bech32/bech32_test.go +++ b/pkg/crypto/ec/bech32/bech32_test.go @@ -13,7 +13,7 @@ import ( "strings" "testing" - "utils.orly" + "next.orly.dev/pkg/utils" ) // TestBech32 tests whether decoding and re-encoding the valid BIP-173 test diff --git a/pkg/crypto/ec/bench_test.go b/pkg/crypto/ec/bench_test.go index 5e8a5fe..2674278 100644 --- a/pkg/crypto/ec/bench_test.go +++ b/pkg/crypto/ec/bench_test.go @@ -8,8 +8,8 @@ import ( "math/big" "testing" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" ) // setHex decodes the passed big-endian hex string into the internal field value diff --git a/pkg/crypto/ec/btcec.go b/pkg/crypto/ec/btcec.go index 969c417..cfa0309 100644 --- a/pkg/crypto/ec/btcec.go +++ b/pkg/crypto/ec/btcec.go @@ -20,7 +20,7 @@ package btcec // reverse the transform than to operate in affine coordinates. import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // KoblitzCurve provides an implementation for secp256k1 that fits the ECC diff --git a/pkg/crypto/ec/chaincfg/deployment_time_frame.go b/pkg/crypto/ec/chaincfg/deployment_time_frame.go index 11ccea6..d9adc02 100644 --- a/pkg/crypto/ec/chaincfg/deployment_time_frame.go +++ b/pkg/crypto/ec/chaincfg/deployment_time_frame.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "crypto.orly/ec/wire" + "next.orly.dev/pkg/crypto/ec/wire" ) var ( diff --git a/pkg/crypto/ec/chaincfg/genesis.go b/pkg/crypto/ec/chaincfg/genesis.go index ac92325..c53e7cc 100644 --- a/pkg/crypto/ec/chaincfg/genesis.go +++ b/pkg/crypto/ec/chaincfg/genesis.go @@ -3,8 +3,8 @@ package chaincfg import ( "time" - "crypto.orly/ec/chainhash" - "crypto.orly/ec/wire" + "next.orly.dev/pkg/crypto/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/wire" ) var ( diff --git a/pkg/crypto/ec/chaincfg/params.go b/pkg/crypto/ec/chaincfg/params.go index 577989c..470541b 100644 --- a/pkg/crypto/ec/chaincfg/params.go +++ b/pkg/crypto/ec/chaincfg/params.go @@ -5,8 +5,8 @@ import ( "math/big" "time" - "crypto.orly/ec/chainhash" - "crypto.orly/ec/wire" + "next.orly.dev/pkg/crypto/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/wire" ) var ( diff --git a/pkg/crypto/ec/chainhash/hash.go b/pkg/crypto/ec/chainhash/hash.go index 93c5f8a..c24d180 100644 --- a/pkg/crypto/ec/chainhash/hash.go +++ b/pkg/crypto/ec/chainhash/hash.go @@ -9,8 +9,8 @@ import ( "encoding/json" "fmt" - "crypto.orly/sha256" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" ) const ( diff --git a/pkg/crypto/ec/chainhash/hash_test.go b/pkg/crypto/ec/chainhash/hash_test.go index 4529d6b..7692d8b 100644 --- a/pkg/crypto/ec/chainhash/hash_test.go +++ b/pkg/crypto/ec/chainhash/hash_test.go @@ -7,7 +7,7 @@ package chainhash import ( "testing" - "utils.orly" + "next.orly.dev/pkg/utils" ) // mainNetGenesisHash is the hash of the first block in the block chain for the diff --git a/pkg/crypto/ec/chainhash/hashfuncs.go b/pkg/crypto/ec/chainhash/hashfuncs.go index ba981e6..a0556a1 100644 --- a/pkg/crypto/ec/chainhash/hashfuncs.go +++ b/pkg/crypto/ec/chainhash/hashfuncs.go @@ -6,7 +6,7 @@ package chainhash import ( - "crypto.orly/sha256" + "next.orly.dev/pkg/crypto/sha256" ) // HashB calculates hash(b) and returns the resulting bytes. diff --git a/pkg/crypto/ec/ciphering.go b/pkg/crypto/ec/ciphering.go index ce1957c..e7cc46c 100644 --- a/pkg/crypto/ec/ciphering.go +++ b/pkg/crypto/ec/ciphering.go @@ -5,7 +5,7 @@ package btcec import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // GenerateSharedSecret generates a shared secret based on a secret key and a diff --git a/pkg/crypto/ec/ciphering_test.go b/pkg/crypto/ec/ciphering_test.go index 2105d01..357d99f 100644 --- a/pkg/crypto/ec/ciphering_test.go +++ b/pkg/crypto/ec/ciphering_test.go @@ -7,7 +7,7 @@ package btcec import ( "testing" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestGenerateSharedSecret(t *testing.T) { diff --git a/pkg/crypto/ec/curve.go b/pkg/crypto/ec/curve.go index 962edad..45de1fb 100644 --- a/pkg/crypto/ec/curve.go +++ b/pkg/crypto/ec/curve.go @@ -6,7 +6,7 @@ package btcec import ( "fmt" - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // JacobianPoint is an element of the group formed by the secp256k1 curve in diff --git a/pkg/crypto/ec/ecdsa/bench_test.go b/pkg/crypto/ec/ecdsa/bench_test.go index 32b51ff..1f6361b 100644 --- a/pkg/crypto/ec/ecdsa/bench_test.go +++ b/pkg/crypto/ec/ecdsa/bench_test.go @@ -8,8 +8,8 @@ package ecdsa import ( "testing" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" ) // hexToModNScalar converts the passed hex string into a ModNScalar and will diff --git a/pkg/crypto/ec/ecdsa/signature.go b/pkg/crypto/ec/ecdsa/signature.go index 9a5beba..46d700b 100644 --- a/pkg/crypto/ec/ecdsa/signature.go +++ b/pkg/crypto/ec/ecdsa/signature.go @@ -8,7 +8,7 @@ package ecdsa import ( "fmt" - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // References: diff --git a/pkg/crypto/ec/ecdsa/signature_test.go b/pkg/crypto/ec/ecdsa/signature_test.go index bf55189..5e00d74 100644 --- a/pkg/crypto/ec/ecdsa/signature_test.go +++ b/pkg/crypto/ec/ecdsa/signature_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) // hexToBytes converts the passed hex string into bytes and will panic if there diff --git a/pkg/crypto/ec/error.go b/pkg/crypto/ec/error.go index d25080e..2e25fda 100644 --- a/pkg/crypto/ec/error.go +++ b/pkg/crypto/ec/error.go @@ -4,7 +4,7 @@ package btcec import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // Error identifies an error related to public key cryptography using a diff --git a/pkg/crypto/ec/field.go b/pkg/crypto/ec/field.go index 2be59bc..c94652f 100644 --- a/pkg/crypto/ec/field.go +++ b/pkg/crypto/ec/field.go @@ -1,7 +1,7 @@ package btcec import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // FieldVal implements optimized fixed-precision arithmetic over the secp256k1 diff --git a/pkg/crypto/ec/field_test.go b/pkg/crypto/ec/field_test.go index 977c3a1..c70fed1 100644 --- a/pkg/crypto/ec/field_test.go +++ b/pkg/crypto/ec/field_test.go @@ -9,8 +9,8 @@ import ( "math/rand" "testing" - "encoders.orly/hex" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/hex" ) // TestIsZero ensures that checking if a field IsZero works as expected. diff --git a/pkg/crypto/ec/fuzz_test.go b/pkg/crypto/ec/fuzz_test.go index d668045..94f88c3 100644 --- a/pkg/crypto/ec/fuzz_test.go +++ b/pkg/crypto/ec/fuzz_test.go @@ -11,7 +11,7 @@ package btcec import ( "testing" - "encoders.orly/hex" + "next.orly.dev/pkg/encoders/hex" ) func FuzzParsePubKey(f *testing.F) { diff --git a/pkg/crypto/ec/modnscalar.go b/pkg/crypto/ec/modnscalar.go index 4499705..945d603 100644 --- a/pkg/crypto/ec/modnscalar.go +++ b/pkg/crypto/ec/modnscalar.go @@ -4,7 +4,7 @@ package btcec import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // ModNScalar implements optimized 256-bit constant-time fixed-precision diff --git a/pkg/crypto/ec/musig2/bench_test.go b/pkg/crypto/ec/musig2/bench_test.go index f70dc1c..19f2854 100644 --- a/pkg/crypto/ec/musig2/bench_test.go +++ b/pkg/crypto/ec/musig2/bench_test.go @@ -8,9 +8,9 @@ import ( "fmt" "testing" - "crypto.orly/ec" - "crypto.orly/ec/schnorr" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/encoders/hex" ) var ( diff --git a/pkg/crypto/ec/musig2/context.go b/pkg/crypto/ec/musig2/context.go index 80b38eb..c0858dd 100644 --- a/pkg/crypto/ec/musig2/context.go +++ b/pkg/crypto/ec/musig2/context.go @@ -5,9 +5,9 @@ package musig2 import ( "fmt" - "crypto.orly/ec" - "crypto.orly/ec/schnorr" "lol.mleku.dev/chk" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/schnorr" ) var ( diff --git a/pkg/crypto/ec/musig2/keys.go b/pkg/crypto/ec/musig2/keys.go index 906a220..07e5e22 100644 --- a/pkg/crypto/ec/musig2/keys.go +++ b/pkg/crypto/ec/musig2/keys.go @@ -7,12 +7,12 @@ import ( "fmt" "sort" - "utils.orly" + "next.orly.dev/pkg/utils" - "crypto.orly/ec" - "crypto.orly/ec/chainhash" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) var ( diff --git a/pkg/crypto/ec/musig2/keys_test.go b/pkg/crypto/ec/musig2/keys_test.go index 62cd1ad..3ac79b9 100644 --- a/pkg/crypto/ec/musig2/keys_test.go +++ b/pkg/crypto/ec/musig2/keys_test.go @@ -10,10 +10,10 @@ import ( "strings" "testing" - "crypto.orly/ec" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" "github.com/stretchr/testify/require" ) diff --git a/pkg/crypto/ec/musig2/musig2_test.go b/pkg/crypto/ec/musig2/musig2_test.go index cb25305..04c07e5 100644 --- a/pkg/crypto/ec/musig2/musig2_test.go +++ b/pkg/crypto/ec/musig2/musig2_test.go @@ -8,9 +8,9 @@ import ( "sync" "testing" - "crypto.orly/ec" - "crypto.orly/sha256" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" ) const ( diff --git a/pkg/crypto/ec/musig2/nonces.go b/pkg/crypto/ec/musig2/nonces.go index ddb5723..7d8adc5 100644 --- a/pkg/crypto/ec/musig2/nonces.go +++ b/pkg/crypto/ec/musig2/nonces.go @@ -9,10 +9,10 @@ import ( "errors" "io" - "crypto.orly/ec" - "crypto.orly/ec/chainhash" - "crypto.orly/ec/schnorr" "lol.mleku.dev/chk" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/schnorr" ) const ( diff --git a/pkg/crypto/ec/musig2/nonces_test.go b/pkg/crypto/ec/musig2/nonces_test.go index 5e19e54..7799003 100644 --- a/pkg/crypto/ec/musig2/nonces_test.go +++ b/pkg/crypto/ec/musig2/nonces_test.go @@ -9,9 +9,9 @@ import ( "path" "testing" - "encoders.orly/hex" "github.com/stretchr/testify/require" - "utils.orly" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) type nonceGenTestCase struct { diff --git a/pkg/crypto/ec/musig2/sign.go b/pkg/crypto/ec/musig2/sign.go index be19059..a8020bb 100644 --- a/pkg/crypto/ec/musig2/sign.go +++ b/pkg/crypto/ec/musig2/sign.go @@ -7,12 +7,12 @@ import ( "fmt" "io" - "crypto.orly/ec" - "crypto.orly/ec/chainhash" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/utils" ) var ( diff --git a/pkg/crypto/ec/musig2/sign_test.go b/pkg/crypto/ec/musig2/sign_test.go index 8cd4f3a..9e33442 100644 --- a/pkg/crypto/ec/musig2/sign_test.go +++ b/pkg/crypto/ec/musig2/sign_test.go @@ -11,10 +11,10 @@ import ( "strings" "testing" - "crypto.orly/ec" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" "github.com/stretchr/testify/require" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" ) const ( diff --git a/pkg/crypto/ec/pubkey.go b/pkg/crypto/ec/pubkey.go index 7b0272b..d69a169 100644 --- a/pkg/crypto/ec/pubkey.go +++ b/pkg/crypto/ec/pubkey.go @@ -5,7 +5,7 @@ package btcec import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // These constants define the lengths of serialized public keys. diff --git a/pkg/crypto/ec/pubkey_test.go b/pkg/crypto/ec/pubkey_test.go index e9396c2..5145c20 100644 --- a/pkg/crypto/ec/pubkey_test.go +++ b/pkg/crypto/ec/pubkey_test.go @@ -7,7 +7,7 @@ package btcec import ( "testing" - "utils.orly" + "next.orly.dev/pkg/utils" "github.com/davecgh/go-spew/spew" ) diff --git a/pkg/crypto/ec/schnorr/bench_test.go b/pkg/crypto/ec/schnorr/bench_test.go index d709de0..3c40629 100644 --- a/pkg/crypto/ec/schnorr/bench_test.go +++ b/pkg/crypto/ec/schnorr/bench_test.go @@ -9,10 +9,10 @@ import ( "math/big" "testing" - "crypto.orly/ec" - "crypto.orly/ec/secp256k1" - "crypto.orly/sha256" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" ) // hexToBytes converts the passed hex string into bytes and will panic if there diff --git a/pkg/crypto/ec/schnorr/pubkey.go b/pkg/crypto/ec/schnorr/pubkey.go index 9d0109d..7bdabfe 100644 --- a/pkg/crypto/ec/schnorr/pubkey.go +++ b/pkg/crypto/ec/schnorr/pubkey.go @@ -8,8 +8,8 @@ package schnorr import ( "fmt" - "crypto.orly/ec" - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // These constants define the lengths of serialized public keys. diff --git a/pkg/crypto/ec/schnorr/signature.go b/pkg/crypto/ec/schnorr/signature.go index 0e6b30d..9838ed8 100644 --- a/pkg/crypto/ec/schnorr/signature.go +++ b/pkg/crypto/ec/schnorr/signature.go @@ -5,10 +5,10 @@ package schnorr import ( "fmt" - "crypto.orly/ec" - "crypto.orly/ec/chainhash" - "crypto.orly/ec/secp256k1" "lol.mleku.dev/chk" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) const ( diff --git a/pkg/crypto/ec/schnorr/signature_test.go b/pkg/crypto/ec/schnorr/signature_test.go index 5aa78ee..4c9b4ff 100644 --- a/pkg/crypto/ec/schnorr/signature_test.go +++ b/pkg/crypto/ec/schnorr/signature_test.go @@ -11,10 +11,10 @@ import ( "testing" "testing/quick" - "crypto.orly/ec" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" "lol.mleku.dev/chk" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" "github.com/davecgh/go-spew/spew" ) diff --git a/pkg/crypto/ec/seckey.go b/pkg/crypto/ec/seckey.go index 63335df..2c47547 100644 --- a/pkg/crypto/ec/seckey.go +++ b/pkg/crypto/ec/seckey.go @@ -5,7 +5,7 @@ package btcec import ( - "crypto.orly/ec/secp256k1" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // SecretKey wraps an ecdsa.SecretKey as a convenience mainly for signing things with the secret key without having to diff --git a/pkg/crypto/ec/secp256k1/curve.go b/pkg/crypto/ec/secp256k1/curve.go index 7405c4d..1df990e 100644 --- a/pkg/crypto/ec/secp256k1/curve.go +++ b/pkg/crypto/ec/secp256k1/curve.go @@ -8,7 +8,7 @@ package secp256k1 import ( "math/bits" - "encoders.orly/hex" + "next.orly.dev/pkg/encoders/hex" ) // References: diff --git a/pkg/crypto/ec/secp256k1/ecdh_test.go b/pkg/crypto/ec/secp256k1/ecdh_test.go index db6d392..88e43ce 100644 --- a/pkg/crypto/ec/secp256k1/ecdh_test.go +++ b/pkg/crypto/ec/secp256k1/ecdh_test.go @@ -8,7 +8,7 @@ package secp256k1 import ( "testing" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestGenerateSharedSecret(t *testing.T) { diff --git a/pkg/crypto/ec/secp256k1/example_test.go b/pkg/crypto/ec/secp256k1/example_test.go index 51e4d5a..482868a 100644 --- a/pkg/crypto/ec/secp256k1/example_test.go +++ b/pkg/crypto/ec/secp256k1/example_test.go @@ -11,9 +11,9 @@ import ( "encoding/binary" "fmt" - "crypto.orly/ec/secp256k1" - "crypto.orly/sha256" - "encoders.orly/hex" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" ) // This example demonstrates use of GenerateSharedSecret to encrypt a message diff --git a/pkg/crypto/ec/secp256k1/field.go b/pkg/crypto/ec/secp256k1/field.go index 2c89c12..4cf12d1 100644 --- a/pkg/crypto/ec/secp256k1/field.go +++ b/pkg/crypto/ec/secp256k1/field.go @@ -52,7 +52,7 @@ package secp256k1 // ordinarily would. See the documentation for FieldVal for more details. import ( - "encoders.orly/hex" + "next.orly.dev/pkg/encoders/hex" ) // Constants used to make the code more readable. diff --git a/pkg/crypto/ec/secp256k1/field_test.go b/pkg/crypto/ec/secp256k1/field_test.go index 3e7bce9..b31bd2b 100644 --- a/pkg/crypto/ec/secp256k1/field_test.go +++ b/pkg/crypto/ec/secp256k1/field_test.go @@ -14,9 +14,9 @@ import ( "testing" "time" - "encoders.orly/hex" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) // SetHex decodes the passed big-endian hex string into the internal field value diff --git a/pkg/crypto/ec/secp256k1/modnscalar.go b/pkg/crypto/ec/secp256k1/modnscalar.go index d7b8c25..cb84a85 100644 --- a/pkg/crypto/ec/secp256k1/modnscalar.go +++ b/pkg/crypto/ec/secp256k1/modnscalar.go @@ -7,7 +7,7 @@ package secp256k1 import ( "math/big" - "encoders.orly/hex" + "next.orly.dev/pkg/encoders/hex" ) // References: diff --git a/pkg/crypto/ec/secp256k1/modnscalar_test.go b/pkg/crypto/ec/secp256k1/modnscalar_test.go index 195371b..98b4758 100644 --- a/pkg/crypto/ec/secp256k1/modnscalar_test.go +++ b/pkg/crypto/ec/secp256k1/modnscalar_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "encoders.orly/hex" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) // SetHex interprets the provided hex string as a 256-bit big-endian unsigned diff --git a/pkg/crypto/ec/secp256k1/nonce.go b/pkg/crypto/ec/secp256k1/nonce.go index 125e122..2a1fe9c 100644 --- a/pkg/crypto/ec/secp256k1/nonce.go +++ b/pkg/crypto/ec/secp256k1/nonce.go @@ -9,7 +9,7 @@ import ( "bytes" "hash" - "crypto.orly/sha256" + "next.orly.dev/pkg/crypto/sha256" ) // References: diff --git a/pkg/crypto/ec/secp256k1/nonce_test.go b/pkg/crypto/ec/secp256k1/nonce_test.go index f25b269..e3a1a91 100644 --- a/pkg/crypto/ec/secp256k1/nonce_test.go +++ b/pkg/crypto/ec/secp256k1/nonce_test.go @@ -8,9 +8,9 @@ package secp256k1 import ( "testing" - "crypto.orly/sha256" - "encoders.orly/hex" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) // hexToBytes converts the passed hex string into bytes and will panic if there diff --git a/pkg/crypto/ec/secp256k1/precomps/genprecomps.go b/pkg/crypto/ec/secp256k1/precomps/genprecomps.go index 3843837..464bbda 100644 --- a/pkg/crypto/ec/secp256k1/precomps/genprecomps.go +++ b/pkg/crypto/ec/secp256k1/precomps/genprecomps.go @@ -13,9 +13,9 @@ import ( "math/big" "os" - "crypto.orly/ec/secp256k1" "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/crypto/ec/secp256k1" ) // curveParams houses the secp256k1 curve parameters for convenient access. diff --git a/pkg/crypto/ec/secp256k1/pubkey_test.go b/pkg/crypto/ec/secp256k1/pubkey_test.go index f0f3074..186a3a4 100644 --- a/pkg/crypto/ec/secp256k1/pubkey_test.go +++ b/pkg/crypto/ec/secp256k1/pubkey_test.go @@ -9,7 +9,7 @@ import ( "errors" "testing" - "utils.orly" + "next.orly.dev/pkg/utils" ) // TestParsePubKey ensures that public keys are properly parsed according diff --git a/pkg/crypto/ec/secp256k1/seckey_test.go b/pkg/crypto/ec/secp256k1/seckey_test.go index 69d4fb4..afaf9ca 100644 --- a/pkg/crypto/ec/secp256k1/seckey_test.go +++ b/pkg/crypto/ec/secp256k1/seckey_test.go @@ -12,7 +12,7 @@ import ( "math/big" "testing" - "utils.orly" + "next.orly.dev/pkg/utils" ) // TestGenerateSecretKey ensures the key generation works as expected. diff --git a/pkg/crypto/ec/taproot/taproot.go b/pkg/crypto/ec/taproot/taproot.go index 4c433d4..f3c247b 100644 --- a/pkg/crypto/ec/taproot/taproot.go +++ b/pkg/crypto/ec/taproot/taproot.go @@ -7,10 +7,10 @@ import ( "errors" "fmt" - "crypto.orly/ec/bech32" - "crypto.orly/ec/chaincfg" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/bech32" + "next.orly.dev/pkg/crypto/ec/chaincfg" + "next.orly.dev/pkg/utils" ) // AddressSegWit is the base address type for all SegWit addresses. diff --git a/pkg/crypto/ec/wire/blockheader.go b/pkg/crypto/ec/wire/blockheader.go index b86c599..1490858 100644 --- a/pkg/crypto/ec/wire/blockheader.go +++ b/pkg/crypto/ec/wire/blockheader.go @@ -3,7 +3,7 @@ package wire import ( "time" - "crypto.orly/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/chainhash" ) // BlockHeader defines information about a block and is used in the bitcoin diff --git a/pkg/crypto/ec/wire/msgtx.go b/pkg/crypto/ec/wire/msgtx.go index 29557ea..aa53ed2 100644 --- a/pkg/crypto/ec/wire/msgtx.go +++ b/pkg/crypto/ec/wire/msgtx.go @@ -1,7 +1,7 @@ package wire import ( - "crypto.orly/ec/chainhash" + "next.orly.dev/pkg/crypto/ec/chainhash" ) // OutPoint defines a bitcoin data type that is used to track previous diff --git a/pkg/crypto/go.mod b/pkg/crypto/go.mod deleted file mode 100644 index 492ad79..0000000 --- a/pkg/crypto/go.mod +++ /dev/null @@ -1,35 +0,0 @@ -module crypto.orly - -go 1.25.0 - -require ( - encoders.orly v0.0.0-00010101000000-000000000000 - github.com/davecgh/go-spew v1.1.1 - github.com/klauspost/cpuid/v2 v2.3.0 - github.com/stretchr/testify v1.11.1 - interfaces.orly v0.0.0-00010101000000-000000000000 - lol.mleku.dev v1.0.2 - utils.orly v0.0.0-00010101000000-000000000000 -) - -require ( - github.com/fatih/color v1.18.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/templexxx/cpu v0.0.1 // indirect - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b // indirect - golang.org/x/sys v0.35.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) diff --git a/pkg/crypto/go.sum b/pkg/crypto/go.sum deleted file mode 100644 index 2fd8356..0000000 --- a/pkg/crypto/go.sum +++ /dev/null @@ -1,27 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b/go.mod h1:7rwmCH0wC2fQvNEvPZ3sKXukhyCTyiaZ5VTZMQYpZKQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= diff --git a/pkg/crypto/p256k/btcec.go b/pkg/crypto/p256k/btcec.go index bfa4b7d..d6a6286 100644 --- a/pkg/crypto/p256k/btcec.go +++ b/pkg/crypto/p256k/btcec.go @@ -3,8 +3,8 @@ package p256k import ( - "crypto.orly/p256k/btcec" "lol.mleku.dev/log" + "next.orly.dev/pkg/crypto/p256k/btcec" ) func init() { diff --git a/pkg/crypto/p256k/btcec/btcec.go b/pkg/crypto/p256k/btcec/btcec.go index 4a7cbc4..5e3d78c 100644 --- a/pkg/crypto/p256k/btcec/btcec.go +++ b/pkg/crypto/p256k/btcec/btcec.go @@ -4,11 +4,11 @@ package btcec import ( - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" - "interfaces.orly/signer" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/interfaces/signer" ) // Signer is an implementation of signer.I that uses the btcec library. diff --git a/pkg/crypto/p256k/btcec/btcec_test.go b/pkg/crypto/p256k/btcec/btcec_test.go index 8e1c437..7209bcd 100644 --- a/pkg/crypto/p256k/btcec/btcec_test.go +++ b/pkg/crypto/p256k/btcec/btcec_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" - "crypto.orly/p256k/btcec" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly" + "next.orly.dev/pkg/crypto/p256k/btcec" + "next.orly.dev/pkg/utils" ) func TestSigner_Generate(t *testing.T) { diff --git a/pkg/crypto/p256k/btcec/helpers-btcec.go b/pkg/crypto/p256k/btcec/helpers-btcec.go index 7072c46..ef53aa8 100644 --- a/pkg/crypto/p256k/btcec/helpers-btcec.go +++ b/pkg/crypto/p256k/btcec/helpers-btcec.go @@ -3,9 +3,9 @@ package btcec import ( - "encoders.orly/hex" - "interfaces.orly/signer" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/interfaces/signer" ) func NewSecFromHex[V []byte | string](skh V) (sign signer.I, err error) { diff --git a/pkg/crypto/p256k/helpers.go b/pkg/crypto/p256k/helpers.go index 65dd6a2..1f4a740 100644 --- a/pkg/crypto/p256k/helpers.go +++ b/pkg/crypto/p256k/helpers.go @@ -3,9 +3,9 @@ package p256k import ( - "encoders.orly/hex" - "interfaces.orly/signer" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/interfaces/signer" ) func NewSecFromHex[V []byte | string](skh V) (sign signer.I, err error) { diff --git a/pkg/crypto/p256k/p256k.go b/pkg/crypto/p256k/p256k.go index d521297..c44d653 100644 --- a/pkg/crypto/p256k/p256k.go +++ b/pkg/crypto/p256k/p256k.go @@ -4,12 +4,12 @@ package p256k import "C" import ( - "crypto.orly/ec" - "crypto.orly/ec/secp256k1" - "interfaces.orly/signer" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/interfaces/signer" ) func init() { diff --git a/pkg/crypto/p256k/p256k_test.go b/pkg/crypto/p256k/p256k_test.go index e24f517..c08e9d4 100644 --- a/pkg/crypto/p256k/p256k_test.go +++ b/pkg/crypto/p256k/p256k_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - "crypto.orly/p256k" - "interfaces.orly/signer" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/interfaces/signer" + "next.orly.dev/pkg/utils" ) func TestSigner_Generate(t *testing.T) { diff --git a/pkg/crypto/p256k/secp256k1.go b/pkg/crypto/p256k/secp256k1.go index 420d8e9..c76bb5e 100644 --- a/pkg/crypto/p256k/secp256k1.go +++ b/pkg/crypto/p256k/secp256k1.go @@ -6,12 +6,12 @@ import ( "crypto/rand" "unsafe" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" - "crypto.orly/sha256" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/crypto/sha256" ) /* diff --git a/pkg/crypto/sha256/sha256.go b/pkg/crypto/sha256/sha256.go index a3514b5..bfe857f 100644 --- a/pkg/crypto/sha256/sha256.go +++ b/pkg/crypto/sha256/sha256.go @@ -412,10 +412,10 @@ func (d *digest) MarshalBinary() ([]byte, error) { func (d *digest) UnmarshalBinary(b []byte) error { if len(b) < len(magic256) || string(b[:len(magic256)]) != magic256 { - return errors.New("crypto.orly/sha256: invalid hash state identifier") + return errors.New("next.orly.dev/pkg/crypto/sha256: invalid hash state identifier") } if len(b) != marshaledSize { - return errors.New("crypto.orly/sha256: invalid hash state size") + return errors.New("next.orly.dev/pkg/crypto/sha256: invalid hash state size") } b = b[len(magic256):] b, d.h[0] = consumeUint32(b) diff --git a/pkg/crypto/sha256/sha256_test.go b/pkg/crypto/sha256/sha256_test.go index 700b4e2..ac6cca8 100644 --- a/pkg/crypto/sha256/sha256_test.go +++ b/pkg/crypto/sha256/sha256_test.go @@ -59,7 +59,7 @@ import ( "testing" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/utils" ) type sha256Test struct { diff --git a/pkg/database/database.go b/pkg/database/database.go index 75da2ee..70fcc40 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -12,8 +12,8 @@ import ( "lol.mleku.dev" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly/apputil" - "utils.orly/units" + "next.orly.dev/pkg/utils/apputil" + "next.orly.dev/pkg/utils/units" ) type D struct { diff --git a/pkg/database/delete-event.go b/pkg/database/delete-event.go index 5791343..5bccde5 100644 --- a/pkg/database/delete-event.go +++ b/pkg/database/delete-event.go @@ -4,11 +4,11 @@ import ( "bytes" "context" - "database.orly/indexes" - "database.orly/indexes/types" - "encoders.orly/event" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" ) // DeleteEvent removes an event from the database identified by `eid`. If diff --git a/pkg/database/delete-expired.go b/pkg/database/delete-expired.go index 9906146..5cf601d 100644 --- a/pkg/database/delete-expired.go +++ b/pkg/database/delete-expired.go @@ -5,11 +5,11 @@ import ( "context" "time" - "database.orly/indexes" - "database.orly/indexes/types" - "encoders.orly/event" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" ) func (d *D) DeleteExpired() { diff --git a/pkg/database/export.go b/pkg/database/export.go index fb31b67..20327bd 100644 --- a/pkg/database/export.go +++ b/pkg/database/export.go @@ -5,12 +5,12 @@ import ( "context" "io" - "database.orly/indexes" - "database.orly/indexes/types" - "encoders.orly/event" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" - "utils.orly/units" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/utils/units" ) // Export the complete database of stored events to an io.Writer in line structured minified diff --git a/pkg/database/export_test.go b/pkg/database/export_test.go index 99ebd9d..53e6b63 100644 --- a/pkg/database/export_test.go +++ b/pkg/database/export_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" ) // TestExport tests the Export function by: diff --git a/pkg/database/fetch-event-by-serial.go b/pkg/database/fetch-event-by-serial.go index 728b39e..467fd93 100644 --- a/pkg/database/fetch-event-by-serial.go +++ b/pkg/database/fetch-event-by-serial.go @@ -3,11 +3,11 @@ package database import ( "bytes" - "database.orly/indexes" - "database.orly/indexes/types" - "encoders.orly/event" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" ) func (d *D) FetchEventBySerial(ser *types.Uint40) (ev *event.E, err error) { diff --git a/pkg/database/fetch-event-by-serial_test.go b/pkg/database/fetch-event-by-serial_test.go index aa17326..3015a73 100644 --- a/pkg/database/fetch-event-by-serial_test.go +++ b/pkg/database/fetch-event-by-serial_test.go @@ -7,13 +7,13 @@ import ( "os" "testing" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/tag" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/utils" ) func TestFetchEventBySerial(t *testing.T) { diff --git a/pkg/database/get-fullidpubkey-by-serial.go b/pkg/database/get-fullidpubkey-by-serial.go index 73e98e6..8d464da 100644 --- a/pkg/database/get-fullidpubkey-by-serial.go +++ b/pkg/database/get-fullidpubkey-by-serial.go @@ -3,11 +3,11 @@ package database import ( "bytes" - "database.orly/indexes" - "database.orly/indexes/types" "github.com/dgraph-io/badger/v4" - "interfaces.orly/store" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/interfaces/store" ) func (d *D) GetFullIdPubkeyBySerial(ser *types.Uint40) ( diff --git a/pkg/database/get-fullidpubkey-by-serials.go b/pkg/database/get-fullidpubkey-by-serials.go index 55576f4..d23af6e 100644 --- a/pkg/database/get-fullidpubkey-by-serials.go +++ b/pkg/database/get-fullidpubkey-by-serials.go @@ -3,11 +3,11 @@ package database import ( "bytes" - "database.orly/indexes" - "database.orly/indexes/types" "github.com/dgraph-io/badger/v4" - "interfaces.orly/store" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/interfaces/store" ) // GetFullIdPubkeyBySerials seeks directly to each serial's prefix in the diff --git a/pkg/database/get-indexes-for-event.go b/pkg/database/get-indexes-for-event.go index bcbcaa1..262b7e9 100644 --- a/pkg/database/get-indexes-for-event.go +++ b/pkg/database/get-indexes-for-event.go @@ -3,10 +3,10 @@ package database import ( "bytes" - "database.orly/indexes" - . "database.orly/indexes/types" - "encoders.orly/event" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes" + . "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" ) // appendIndexBytes marshals an index to a byte slice and appends it to the idxs slice diff --git a/pkg/database/get-indexes-for-event_test.go b/pkg/database/get-indexes-for-event_test.go index 83f7e0a..5e3eebc 100644 --- a/pkg/database/get-indexes-for-event_test.go +++ b/pkg/database/get-indexes-for-event_test.go @@ -4,14 +4,14 @@ import ( "bytes" "testing" - "crypto.orly/sha256" - "database.orly/indexes" - types2 "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/kind" - "encoders.orly/tag" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/database/indexes" + types2 "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/utils" ) func TestGetIndexesForEvent(t *testing.T) { diff --git a/pkg/database/get-indexes-from-filter.go b/pkg/database/get-indexes-from-filter.go index 2e6e2a4..8ce1867 100644 --- a/pkg/database/get-indexes-from-filter.go +++ b/pkg/database/get-indexes-from-filter.go @@ -5,11 +5,11 @@ import ( "math" "sort" - "database.orly/indexes" - types2 "database.orly/indexes/types" - "encoders.orly/filter" "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/database/indexes" + types2 "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/filter" ) type Range struct { diff --git a/pkg/database/get-indexes-from-filter_test.go b/pkg/database/get-indexes-from-filter_test.go index 5de05fb..bde09cd 100644 --- a/pkg/database/get-indexes-from-filter_test.go +++ b/pkg/database/get-indexes-from-filter_test.go @@ -5,15 +5,15 @@ import ( "math" "testing" - "crypto.orly/sha256" - "database.orly/indexes" - types2 "database.orly/indexes/types" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/database/indexes" + types2 "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils" ) // TestGetIndexesFromFilter tests the GetIndexesFromFilter function diff --git a/pkg/database/get-serial-by-id.go b/pkg/database/get-serial-by-id.go index a2c4cf9..0220de1 100644 --- a/pkg/database/get-serial-by-id.go +++ b/pkg/database/get-serial-by-id.go @@ -3,14 +3,14 @@ package database import ( "bytes" - "database.orly/indexes/types" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/tag" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/tag" ) func (d *D) GetSerialById(id []byte) (ser *types.Uint40, err error) { diff --git a/pkg/database/get-serial-by-id_test.go b/pkg/database/get-serial-by-id_test.go index 7822f19..a7ad6a5 100644 --- a/pkg/database/get-serial-by-id_test.go +++ b/pkg/database/get-serial-by-id_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" ) func TestGetSerialById(t *testing.T) { diff --git a/pkg/database/get-serials-by-range.go b/pkg/database/get-serials-by-range.go index 5514712..3fff222 100644 --- a/pkg/database/get-serials-by-range.go +++ b/pkg/database/get-serials-by-range.go @@ -4,9 +4,9 @@ import ( "bytes" "sort" - "database.orly/indexes/types" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes/types" ) func (d *D) GetSerialsByRange(idx Range) ( diff --git a/pkg/database/get-serials-by-range_test.go b/pkg/database/get-serials-by-range_test.go index 9664377..134dedd 100644 --- a/pkg/database/get-serials-by-range_test.go +++ b/pkg/database/get-serials-by-range_test.go @@ -7,15 +7,15 @@ import ( "os" "testing" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils" ) func TestGetSerialsByRange(t *testing.T) { diff --git a/pkg/database/go.mod b/pkg/database/go.mod deleted file mode 100644 index a9d29b4..0000000 --- a/pkg/database/go.mod +++ /dev/null @@ -1,53 +0,0 @@ -module database.orly - -go 1.25.0 - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) - -require ( - crypto.orly v0.0.0-00010101000000-000000000000 - encoders.orly v0.0.0-00010101000000-000000000000 - github.com/dgraph-io/badger/v4 v4.8.0 - go.uber.org/atomic v1.11.0 - interfaces.orly v0.0.0-00010101000000-000000000000 - lol.mleku.dev v1.0.2 - lukechampine.com/frand v1.5.1 - utils.orly v0.0.0-00010101000000-000000000000 -) - -require ( - github.com/adrg/xdg v0.5.3 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect - github.com/dustin/go-humanize v1.0.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/go-logr/logr v1.4.3 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/google/flatbuffers v25.2.10+incompatible // indirect - github.com/klauspost/compress v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/templexxx/cpu v0.0.1 // indirect - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b // indirect - go-simpler.org/env v0.12.0 // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel v1.37.0 // indirect - go.opentelemetry.io/otel/metric v1.37.0 // indirect - go.opentelemetry.io/otel/trace v1.37.0 // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect - golang.org/x/net v0.41.0 // indirect - golang.org/x/sys v0.35.0 // indirect - google.golang.org/protobuf v1.36.6 // indirect - next.orly.dev v0.0.0-00010101000000-000000000000 // indirect -) diff --git a/pkg/database/go.sum b/pkg/database/go.sum deleted file mode 100644 index 9d8dce4..0000000 --- a/pkg/database/go.sum +++ /dev/null @@ -1,68 +0,0 @@ -github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= -github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v4 v4.8.0 h1:JYph1ChBijCw8SLeybvPINizbDKWZ5n/GYbz2yhN/bs= -github.com/dgraph-io/badger/v4 v4.8.0/go.mod h1:U6on6e8k/RTbUWxqKR0MvugJuVmkxSNc79ap4917h4w= -github.com/dgraph-io/ristretto/v2 v2.2.0 h1:bkY3XzJcXoMuELV8F+vS8kzNgicwQFAaGINAEJdWGOM= -github.com/dgraph-io/ristretto/v2 v2.2.0/go.mod h1:RZrm63UmcBAaYWC1DotLYBmTvgkrs0+XhBd7Npn7/zI= -github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38= -github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= -github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q= -github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= -github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= -github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= -github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b/go.mod h1:7rwmCH0wC2fQvNEvPZ3sKXukhyCTyiaZ5VTZMQYpZKQ= -go-simpler.org/env v0.12.0 h1:kt/lBts0J1kjWJAnB740goNdvwNxt5emhYngL0Fzufs= -go-simpler.org/env v0.12.0/go.mod h1:cc/5Md9JCUM7LVLtN0HYjPTDcI3Q8TDaPlNTAlDU+WI= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= -go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= -go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= -go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= -go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= -go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= -golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= -google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= -lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= -lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= diff --git a/pkg/database/import.go b/pkg/database/import.go index 6e30586..59efd34 100644 --- a/pkg/database/import.go +++ b/pkg/database/import.go @@ -6,9 +6,9 @@ import ( "os" "runtime/debug" - "encoders.orly/event" "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/encoders/event" ) const maxLen = 500000000 diff --git a/pkg/database/indexes/keys.go b/pkg/database/indexes/keys.go index 25e6d01..84cc13f 100644 --- a/pkg/database/indexes/keys.go +++ b/pkg/database/indexes/keys.go @@ -4,9 +4,9 @@ import ( "io" "reflect" - "database.orly/indexes/types" - "interfaces.orly/codec" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/interfaces/codec" ) var counter int diff --git a/pkg/database/indexes/keys_test.go b/pkg/database/indexes/keys_test.go index c1800c0..0ea1036 100644 --- a/pkg/database/indexes/keys_test.go +++ b/pkg/database/indexes/keys_test.go @@ -5,9 +5,9 @@ import ( "io" "testing" - "database.orly/indexes/types" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/utils" ) // TestNewPrefix tests the NewPrefix function with and without arguments diff --git a/pkg/database/indexes/types/fullid.go b/pkg/database/indexes/types/fullid.go index 8b72f3f..ccd409a 100644 --- a/pkg/database/indexes/types/fullid.go +++ b/pkg/database/indexes/types/fullid.go @@ -3,8 +3,8 @@ package types import ( "io" - "crypto.orly/sha256" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/crypto/sha256" ) const IdLen = sha256.Size diff --git a/pkg/database/indexes/types/fullid_test.go b/pkg/database/indexes/types/fullid_test.go index fb0e6aa..809607a 100644 --- a/pkg/database/indexes/types/fullid_test.go +++ b/pkg/database/indexes/types/fullid_test.go @@ -5,9 +5,9 @@ import ( "testing" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/utils" - "crypto.orly/sha256" + "next.orly.dev/pkg/crypto/sha256" ) func TestFromId(t *testing.T) { diff --git a/pkg/database/indexes/types/identhash.go b/pkg/database/indexes/types/identhash.go index 0921408..be3d41f 100644 --- a/pkg/database/indexes/types/identhash.go +++ b/pkg/database/indexes/types/identhash.go @@ -3,7 +3,7 @@ package types import ( "io" - "crypto.orly/sha256" + "next.orly.dev/pkg/crypto/sha256" ) const IdentLen = 8 diff --git a/pkg/database/indexes/types/identhash_test.go b/pkg/database/indexes/types/identhash_test.go index d7bc49b..143a1c2 100644 --- a/pkg/database/indexes/types/identhash_test.go +++ b/pkg/database/indexes/types/identhash_test.go @@ -4,9 +4,9 @@ import ( "bytes" "testing" - "crypto.orly/sha256" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/utils" ) func TestFromIdent(t *testing.T) { diff --git a/pkg/database/indexes/types/idhash.go b/pkg/database/indexes/types/idhash.go index 483a6a4..8cb32ee 100644 --- a/pkg/database/indexes/types/idhash.go +++ b/pkg/database/indexes/types/idhash.go @@ -4,10 +4,10 @@ import ( "encoding/base64" "io" - "crypto.orly/sha256" - "encoders.orly/hex" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" ) const IdHashLen = 8 diff --git a/pkg/database/indexes/types/idhash_test.go b/pkg/database/indexes/types/idhash_test.go index 8e929c9..fb2646e 100644 --- a/pkg/database/indexes/types/idhash_test.go +++ b/pkg/database/indexes/types/idhash_test.go @@ -5,10 +5,10 @@ import ( "encoding/base64" "testing" - "crypto.orly/sha256" - "encoders.orly/hex" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) func TestFromIdHash(t *testing.T) { diff --git a/pkg/database/indexes/types/pubhash.go b/pkg/database/indexes/types/pubhash.go index 1aacda9..d44dcaa 100644 --- a/pkg/database/indexes/types/pubhash.go +++ b/pkg/database/indexes/types/pubhash.go @@ -3,11 +3,11 @@ package types import ( "io" - "crypto.orly/ec/schnorr" - "crypto.orly/sha256" - "encoders.orly/hex" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" ) const PubHashLen = 8 diff --git a/pkg/database/indexes/types/pubhash_test.go b/pkg/database/indexes/types/pubhash_test.go index 65e2295..511588c 100644 --- a/pkg/database/indexes/types/pubhash_test.go +++ b/pkg/database/indexes/types/pubhash_test.go @@ -4,11 +4,11 @@ import ( "bytes" "testing" - "crypto.orly/ec/schnorr" - "crypto.orly/sha256" - "encoders.orly/hex" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) func TestPubHash_FromPubkey(t *testing.T) { diff --git a/pkg/database/indexes/types/uint16_test.go b/pkg/database/indexes/types/uint16_test.go index f398763..667e7a3 100644 --- a/pkg/database/indexes/types/uint16_test.go +++ b/pkg/database/indexes/types/uint16_test.go @@ -8,7 +8,7 @@ import ( "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestUint16(t *testing.T) { diff --git a/pkg/database/indexes/types/uint32_test.go b/pkg/database/indexes/types/uint32_test.go index 3ce4b0b..9b3b468 100644 --- a/pkg/database/indexes/types/uint32_test.go +++ b/pkg/database/indexes/types/uint32_test.go @@ -8,7 +8,7 @@ import ( "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestUint32(t *testing.T) { diff --git a/pkg/database/indexes/types/uint64_test.go b/pkg/database/indexes/types/uint64_test.go index 332778e..e31d9b2 100644 --- a/pkg/database/indexes/types/uint64_test.go +++ b/pkg/database/indexes/types/uint64_test.go @@ -8,7 +8,7 @@ import ( "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestUint64(t *testing.T) { diff --git a/pkg/database/indexes/types/word_test.go b/pkg/database/indexes/types/word_test.go index 601d248..d5de17f 100644 --- a/pkg/database/indexes/types/word_test.go +++ b/pkg/database/indexes/types/word_test.go @@ -4,9 +4,9 @@ import ( "bytes" "testing" - "database.orly/indexes/types" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/utils" ) func TestT(t *testing.T) { diff --git a/pkg/database/migrations.go b/pkg/database/migrations.go index e94888c..a490436 100644 --- a/pkg/database/migrations.go +++ b/pkg/database/migrations.go @@ -4,13 +4,13 @@ import ( "bytes" "sort" - "database.orly/indexes" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/ints" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/ints" ) const ( diff --git a/pkg/database/process-delete.go b/pkg/database/process-delete.go index 31a249a..3cba3ea 100644 --- a/pkg/database/process-delete.go +++ b/pkg/database/process-delete.go @@ -4,14 +4,14 @@ import ( "context" "sort" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/ints" - "encoders.orly/kind" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" ) func (d *D) ProcessDelete(ev *event.E, admins [][]byte) (err error) { diff --git a/pkg/database/query-events-multiple-param-replaceable_test.go b/pkg/database/query-events-multiple-param-replaceable_test.go index 9e32681..18adac3 100644 --- a/pkg/database/query-events-multiple-param-replaceable_test.go +++ b/pkg/database/query-events-multiple-param-replaceable_test.go @@ -5,15 +5,15 @@ import ( "os" "testing" - "crypto.orly/p256k" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils" ) // TestMultipleParameterizedReplaceableEvents tests that when multiple parameterized diff --git a/pkg/database/query-events.go b/pkg/database/query-events.go index 8c8c31c..0a9a0d5 100644 --- a/pkg/database/query-events.go +++ b/pkg/database/query-events.go @@ -8,18 +8,18 @@ import ( "strings" "time" - "crypto.orly/sha256" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/ints" - "encoders.orly/kind" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func CheckExpiration(ev *event.E) (expired bool) { diff --git a/pkg/database/query-events_test.go b/pkg/database/query-events_test.go index 705a063..29d13a3 100644 --- a/pkg/database/query-events_test.go +++ b/pkg/database/query-events_test.go @@ -8,16 +8,16 @@ import ( "os" "testing" - "crypto.orly/p256k" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils" ) // setupTestDB creates a new test database and loads example events diff --git a/pkg/database/query-for-authors-tags_test.go b/pkg/database/query-for-authors-tags_test.go index 3069e69..c27f3f2 100644 --- a/pkg/database/query-for-authors-tags_test.go +++ b/pkg/database/query-for-authors-tags_test.go @@ -7,13 +7,13 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForAuthorsTags(t *testing.T) { diff --git a/pkg/database/query-for-created-at_test.go b/pkg/database/query-for-created-at_test.go index 419570b..5f44f2e 100644 --- a/pkg/database/query-for-created-at_test.go +++ b/pkg/database/query-for-created-at_test.go @@ -7,13 +7,13 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/timestamp" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForCreatedAt(t *testing.T) { diff --git a/pkg/database/query-for-deleted.go b/pkg/database/query-for-deleted.go index f1f5b31..22bb023 100644 --- a/pkg/database/query-for-deleted.go +++ b/pkg/database/query-for-deleted.go @@ -4,16 +4,16 @@ import ( "fmt" "sort" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/tag/atag" - "interfaces.orly/store" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/tag/atag" + "next.orly.dev/pkg/interfaces/store" ) // CheckForDeleted checks if the event is deleted, and returns an error with diff --git a/pkg/database/query-for-ids.go b/pkg/database/query-for-ids.go index fdd4a5c..e33fc05 100644 --- a/pkg/database/query-for-ids.go +++ b/pkg/database/query-for-ids.go @@ -4,11 +4,11 @@ import ( "context" "sort" - "database.orly/indexes/types" - "encoders.orly/filter" - "interfaces.orly/store" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/interfaces/store" ) // QueryForIds retrieves a list of IdPkTs based on the provided filter. diff --git a/pkg/database/query-for-ids_test.go b/pkg/database/query-for-ids_test.go index d8b4b43..fd89c00 100644 --- a/pkg/database/query-for-ids_test.go +++ b/pkg/database/query-for-ids_test.go @@ -7,15 +7,15 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForIds(t *testing.T) { diff --git a/pkg/database/query-for-kinds-authors-tags_test.go b/pkg/database/query-for-kinds-authors-tags_test.go index 1129162..0d2fc6e 100644 --- a/pkg/database/query-for-kinds-authors-tags_test.go +++ b/pkg/database/query-for-kinds-authors-tags_test.go @@ -7,14 +7,14 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForKindsAuthorsTags(t *testing.T) { diff --git a/pkg/database/query-for-kinds-authors_test.go b/pkg/database/query-for-kinds-authors_test.go index 9a2f1b1..2eb2052 100644 --- a/pkg/database/query-for-kinds-authors_test.go +++ b/pkg/database/query-for-kinds-authors_test.go @@ -7,14 +7,14 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForKindsAuthors(t *testing.T) { diff --git a/pkg/database/query-for-kinds-tags_test.go b/pkg/database/query-for-kinds-tags_test.go index 725814e..e70e722 100644 --- a/pkg/database/query-for-kinds-tags_test.go +++ b/pkg/database/query-for-kinds-tags_test.go @@ -7,14 +7,14 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForKindsTags(t *testing.T) { diff --git a/pkg/database/query-for-kinds_test.go b/pkg/database/query-for-kinds_test.go index 26ebe5e..a5acad2 100644 --- a/pkg/database/query-for-kinds_test.go +++ b/pkg/database/query-for-kinds_test.go @@ -7,13 +7,13 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForKinds(t *testing.T) { diff --git a/pkg/database/query-for-serials.go b/pkg/database/query-for-serials.go index 708e1fd..6657c8b 100644 --- a/pkg/database/query-for-serials.go +++ b/pkg/database/query-for-serials.go @@ -3,10 +3,10 @@ package database import ( "context" - "database.orly/indexes/types" - "encoders.orly/filter" - "interfaces.orly/store" "lol.mleku.dev/chk" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/interfaces/store" ) // QueryForSerials takes a filter and returns the serials of events that match, diff --git a/pkg/database/query-for-serials_test.go b/pkg/database/query-for-serials_test.go index e8c474f..b568f61 100644 --- a/pkg/database/query-for-serials_test.go +++ b/pkg/database/query-for-serials_test.go @@ -7,15 +7,15 @@ import ( "os" "testing" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils" ) func TestQueryForSerials(t *testing.T) { diff --git a/pkg/database/query-for-tags_test.go b/pkg/database/query-for-tags_test.go index 541c5ba..3f84ae9 100644 --- a/pkg/database/query-for-tags_test.go +++ b/pkg/database/query-for-tags_test.go @@ -7,13 +7,13 @@ import ( "os" "testing" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/filter" - "encoders.orly/tag" - "interfaces.orly/store" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/store" + "next.orly.dev/pkg/utils" ) func TestQueryForTags(t *testing.T) { diff --git a/pkg/database/save-event.go b/pkg/database/save-event.go index 548075c..5272d68 100644 --- a/pkg/database/save-event.go +++ b/pkg/database/save-event.go @@ -6,17 +6,17 @@ import ( "fmt" "strings" - "database.orly/indexes" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" "github.com/dgraph-io/badger/v4" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" + "next.orly.dev/pkg/database/indexes" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" ) func (d *D) GetSerialsFromFilter(f *filter.F) ( diff --git a/pkg/database/save-event_test.go b/pkg/database/save-event_test.go index 8873e18..ce4200b 100644 --- a/pkg/database/save-event_test.go +++ b/pkg/database/save-event_test.go @@ -8,15 +8,15 @@ import ( "testing" "time" - "crypto.orly/p256k" - "encoders.orly/event" - "encoders.orly/event/examples" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" ) // TestSaveEvents tests saving all events from examples.Cache to the database diff --git a/pkg/database/subscriptions.go b/pkg/database/subscriptions.go index a39cea0..39678f4 100644 --- a/pkg/database/subscriptions.go +++ b/pkg/database/subscriptions.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "encoders.orly/json" "github.com/dgraph-io/badger/v4" + "next.orly.dev/pkg/encoders/json" ) type Subscription struct { diff --git a/pkg/encoders/bech32encoding/keys.go b/pkg/encoders/bech32encoding/keys.go index 65c5e70..c12b6db 100644 --- a/pkg/encoders/bech32encoding/keys.go +++ b/pkg/encoders/bech32encoding/keys.go @@ -4,15 +4,15 @@ import ( "bytes" "strings" - "crypto.orly/ec" - "crypto.orly/ec/bech32" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" - "encoders.orly/hex" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly" - "utils.orly/constraints" + "next.orly.dev/pkg/crypto/ec" + "next.orly.dev/pkg/crypto/ec/bech32" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/constraints" ) const ( diff --git a/pkg/encoders/bech32encoding/keys_test.go b/pkg/encoders/bech32encoding/keys_test.go index 94c983b..8d092c7 100644 --- a/pkg/encoders/bech32encoding/keys_test.go +++ b/pkg/encoders/bech32encoding/keys_test.go @@ -5,10 +5,10 @@ import ( "encoding/hex" "testing" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/utils" ) func TestConvertBits(t *testing.T) { diff --git a/pkg/encoders/bech32encoding/nip19.go b/pkg/encoders/bech32encoding/nip19.go index 97dd8b7..5e16294 100644 --- a/pkg/encoders/bech32encoding/nip19.go +++ b/pkg/encoders/bech32encoding/nip19.go @@ -4,17 +4,17 @@ import ( "bytes" "encoding/binary" - "crypto.orly/ec/bech32" - "crypto.orly/ec/schnorr" - "crypto.orly/sha256" - "encoders.orly/bech32encoding/pointers" - "encoders.orly/bech32encoding/tlv" - "encoders.orly/hex" - "encoders.orly/kind" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/bech32" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/bech32encoding/pointers" + "next.orly.dev/pkg/encoders/bech32encoding/tlv" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/utils" ) var ( diff --git a/pkg/encoders/bech32encoding/nip19_test.go b/pkg/encoders/bech32encoding/nip19_test.go index bbee541..8a47e65 100644 --- a/pkg/encoders/bech32encoding/nip19_test.go +++ b/pkg/encoders/bech32encoding/nip19_test.go @@ -4,13 +4,13 @@ import ( "reflect" "testing" - "encoders.orly/bech32encoding/pointers" - "encoders.orly/hex" - "encoders.orly/kind" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly" - "utils.orly/constraints" + "next.orly.dev/pkg/encoders/bech32encoding/pointers" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/constraints" ) func TestEncodeNpub(t *testing.T) { diff --git a/pkg/encoders/bech32encoding/pointers/pointers.go b/pkg/encoders/bech32encoding/pointers/pointers.go index 59a14ad..bfa6143 100644 --- a/pkg/encoders/bech32encoding/pointers/pointers.go +++ b/pkg/encoders/bech32encoding/pointers/pointers.go @@ -3,7 +3,7 @@ package pointers import ( - "encoders.orly/kind" + "next.orly.dev/pkg/encoders/kind" ) // Profile pointer is a combination of pubkey and relay list. diff --git a/pkg/encoders/envelopes/authenvelope/authenvelope.go b/pkg/encoders/envelopes/authenvelope/authenvelope.go index 649e502..8c991c5 100644 --- a/pkg/encoders/envelopes/authenvelope/authenvelope.go +++ b/pkg/encoders/envelopes/authenvelope/authenvelope.go @@ -5,14 +5,14 @@ package authenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/event" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly/constraints" - "utils.orly/units" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/utils/constraints" + "next.orly.dev/pkg/utils/units" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/authenvelope/authenvelope_test.go b/pkg/encoders/envelopes/authenvelope/authenvelope_test.go index 6921a89..e9fbc1a 100644 --- a/pkg/encoders/envelopes/authenvelope/authenvelope_test.go +++ b/pkg/encoders/envelopes/authenvelope/authenvelope_test.go @@ -3,12 +3,12 @@ package authenvelope import ( "testing" - "crypto.orly/p256k" - "encoders.orly/envelopes" "lol.mleku.dev/chk" - "protocol.orly/auth" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/protocol/auth" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) const relayURL = "wss://example.com" diff --git a/pkg/encoders/envelopes/closedenvelope/closedenvelope.go b/pkg/encoders/envelopes/closedenvelope/closedenvelope.go index 7dc3cba..309b78f 100644 --- a/pkg/encoders/envelopes/closedenvelope/closedenvelope.go +++ b/pkg/encoders/envelopes/closedenvelope/closedenvelope.go @@ -6,10 +6,10 @@ package closedenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/closedenvelope/closedenvelope_test.go b/pkg/encoders/envelopes/closedenvelope/closedenvelope_test.go index e751829..faadb6a 100644 --- a/pkg/encoders/envelopes/closedenvelope/closedenvelope_test.go +++ b/pkg/encoders/envelopes/closedenvelope/closedenvelope_test.go @@ -5,10 +5,10 @@ import ( "math" "testing" - "encoders.orly/envelopes" "lol.mleku.dev/chk" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" "lukechampine.com/frand" ) diff --git a/pkg/encoders/envelopes/closeenvelope/closeenvelope.go b/pkg/encoders/envelopes/closeenvelope/closeenvelope.go index 63ba543..b523ebf 100644 --- a/pkg/encoders/envelopes/closeenvelope/closeenvelope.go +++ b/pkg/encoders/envelopes/closeenvelope/closeenvelope.go @@ -5,10 +5,10 @@ package closeenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/closeenvelope/closeenvelope_test.go b/pkg/encoders/envelopes/closeenvelope/closeenvelope_test.go index 282d043..ca5798b 100644 --- a/pkg/encoders/envelopes/closeenvelope/closeenvelope_test.go +++ b/pkg/encoders/envelopes/closeenvelope/closeenvelope_test.go @@ -5,11 +5,11 @@ import ( "math" "testing" - "encoders.orly/envelopes" "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/envelopes/countenvelope/countenvelope.go b/pkg/encoders/envelopes/countenvelope/countenvelope.go index bd44cd3..08a3d10 100644 --- a/pkg/encoders/envelopes/countenvelope/countenvelope.go +++ b/pkg/encoders/envelopes/countenvelope/countenvelope.go @@ -6,14 +6,14 @@ import ( "bytes" "io" - "encoders.orly/envelopes" - "encoders.orly/filter" - "encoders.orly/ints" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly/constraints" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/utils/constraints" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/countenvelope/countenvelope_test.go b/pkg/encoders/envelopes/countenvelope/countenvelope_test.go index edb933b..ae7b991 100644 --- a/pkg/encoders/envelopes/countenvelope/countenvelope_test.go +++ b/pkg/encoders/envelopes/countenvelope/countenvelope_test.go @@ -3,12 +3,12 @@ package countenvelope import ( "testing" - "encoders.orly/envelopes" - "encoders.orly/filter" "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) func TestRequest(t *testing.T) { diff --git a/pkg/encoders/envelopes/eoseenvelope/eoseenvelope.go b/pkg/encoders/envelopes/eoseenvelope/eoseenvelope.go index 4bb8121..bb348da 100644 --- a/pkg/encoders/envelopes/eoseenvelope/eoseenvelope.go +++ b/pkg/encoders/envelopes/eoseenvelope/eoseenvelope.go @@ -7,10 +7,10 @@ package eoseenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/eoseenvelope/eoseenvelope_test.go b/pkg/encoders/envelopes/eoseenvelope/eoseenvelope_test.go index 60885a2..fd82c60 100644 --- a/pkg/encoders/envelopes/eoseenvelope/eoseenvelope_test.go +++ b/pkg/encoders/envelopes/eoseenvelope/eoseenvelope_test.go @@ -3,9 +3,9 @@ package eoseenvelope import ( "testing" - "encoders.orly/envelopes" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/utils" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/envelopes/eventenvelope/eventenvelope.go b/pkg/encoders/envelopes/eventenvelope/eventenvelope.go index 42942a2..73a0d06 100644 --- a/pkg/encoders/envelopes/eventenvelope/eventenvelope.go +++ b/pkg/encoders/envelopes/eventenvelope/eventenvelope.go @@ -5,15 +5,15 @@ package eventenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/event" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly/bufpool" - "utils.orly/constraints" - "utils.orly/units" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/utils/bufpool" + "next.orly.dev/pkg/utils/constraints" + "next.orly.dev/pkg/utils/units" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/eventenvelope/eventenvelope_test.go b/pkg/encoders/envelopes/eventenvelope/eventenvelope_test.go index 7ffc418..44c130d 100644 --- a/pkg/encoders/envelopes/eventenvelope/eventenvelope_test.go +++ b/pkg/encoders/envelopes/eventenvelope/eventenvelope_test.go @@ -5,12 +5,12 @@ import ( "bytes" "testing" - "encoders.orly/envelopes" - "encoders.orly/event" - "encoders.orly/event/examples" "lol.mleku.dev/chk" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) func TestSubmission(t *testing.T) { diff --git a/pkg/encoders/envelopes/noticeenvelope/noticeenvelope.go b/pkg/encoders/envelopes/noticeenvelope/noticeenvelope.go index a65a5b1..8488aba 100644 --- a/pkg/encoders/envelopes/noticeenvelope/noticeenvelope.go +++ b/pkg/encoders/envelopes/noticeenvelope/noticeenvelope.go @@ -6,11 +6,11 @@ package noticeenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" - "utils.orly/constraints" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/utils/constraints" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/noticeenvelope/noticeenvelope_test.go b/pkg/encoders/envelopes/noticeenvelope/noticeenvelope_test.go index 529db39..fb907e5 100644 --- a/pkg/encoders/envelopes/noticeenvelope/noticeenvelope_test.go +++ b/pkg/encoders/envelopes/noticeenvelope/noticeenvelope_test.go @@ -3,10 +3,10 @@ package noticeenvelope import ( "testing" - "encoders.orly/envelopes" - "encoders.orly/envelopes/messages" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/envelopes/messages" + "next.orly.dev/pkg/utils" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/envelopes/okenvelope/okenvelope.go b/pkg/encoders/envelopes/okenvelope/okenvelope.go index 12857b9..48dfae6 100644 --- a/pkg/encoders/envelopes/okenvelope/okenvelope.go +++ b/pkg/encoders/envelopes/okenvelope/okenvelope.go @@ -6,15 +6,15 @@ package okenvelope import ( "io" - "crypto.orly/sha256" - "encoders.orly/envelopes" - "encoders.orly/hex" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" - "utils.orly/constraints" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/utils/constraints" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/okenvelope/okenvelope_test.go b/pkg/encoders/envelopes/okenvelope/okenvelope_test.go index 4c0bcc1..276b4fb 100644 --- a/pkg/encoders/envelopes/okenvelope/okenvelope_test.go +++ b/pkg/encoders/envelopes/okenvelope/okenvelope_test.go @@ -3,12 +3,12 @@ package okenvelope import ( "testing" - "crypto.orly/sha256" - "encoders.orly/envelopes" - "encoders.orly/envelopes/messages" "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/envelopes/messages" + "next.orly.dev/pkg/utils" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/envelopes/reqenvelope/reqenvelope.go b/pkg/encoders/envelopes/reqenvelope/reqenvelope.go index dfeca27..1712f97 100644 --- a/pkg/encoders/envelopes/reqenvelope/reqenvelope.go +++ b/pkg/encoders/envelopes/reqenvelope/reqenvelope.go @@ -5,12 +5,12 @@ package reqenvelope import ( "io" - "encoders.orly/envelopes" - "encoders.orly/filter" - "encoders.orly/text" - "interfaces.orly/codec" "lol.mleku.dev/chk" - "utils.orly/constraints" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/utils/constraints" ) // L is the label associated with this type of codec.Envelope. diff --git a/pkg/encoders/envelopes/reqenvelope/reqenvelope_test.go b/pkg/encoders/envelopes/reqenvelope/reqenvelope_test.go index 1fbeecf..a247d3b 100644 --- a/pkg/encoders/envelopes/reqenvelope/reqenvelope_test.go +++ b/pkg/encoders/envelopes/reqenvelope/reqenvelope_test.go @@ -3,11 +3,11 @@ package reqenvelope import ( "testing" - "encoders.orly/envelopes" - "encoders.orly/filter" "lol.mleku.dev/chk" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/event/binary.go b/pkg/encoders/event/binary.go index 8cbcd0b..577b14c 100644 --- a/pkg/encoders/event/binary.go +++ b/pkg/encoders/event/binary.go @@ -3,10 +3,10 @@ package event import ( "io" - "crypto.orly/ec/schnorr" - "encoders.orly/tag" - "encoders.orly/varint" "lol.mleku.dev/chk" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/varint" ) // MarshalBinary writes a binary encoding of an event. diff --git a/pkg/encoders/event/binary_test.go b/pkg/encoders/event/binary_test.go index 989be8f..eb02412 100644 --- a/pkg/encoders/event/binary_test.go +++ b/pkg/encoders/event/binary_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - "encoders.orly/event/examples" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/utils" ) func TestTMarshalBinary_UnmarshalBinary(t *testing.T) { diff --git a/pkg/encoders/event/canonical.go b/pkg/encoders/event/canonical.go index 238d3d3..93f287e 100644 --- a/pkg/encoders/event/canonical.go +++ b/pkg/encoders/event/canonical.go @@ -1,10 +1,10 @@ package event import ( - "crypto.orly/sha256" - "encoders.orly/hex" - "encoders.orly/ints" - "encoders.orly/text" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/text" ) // ToCanonical converts the event to the canonical encoding used to derive the diff --git a/pkg/encoders/event/event.go b/pkg/encoders/event/event.go index 8e295e6..a90ead1 100644 --- a/pkg/encoders/event/event.go +++ b/pkg/encoders/event/event.go @@ -4,18 +4,18 @@ import ( "fmt" "io" - "crypto.orly/ec/schnorr" - "crypto.orly/sha256" - "encoders.orly/ints" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/text" "github.com/templexxx/xhex" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) // E is the primary datatype of nostr. This is the form of the structure that @@ -28,7 +28,7 @@ import ( // library. Either call MarshalJSON directly or use a json.Encoder with html // escaping disabled. // -// Or import "encoders.orly/json" and use json.Marshal which is the +// Or import "next.orly.dev/pkg/encoders/json" and use json.Marshal which is the // same as go 1.25 json v1 except with this one stupidity removed. type E struct { diff --git a/pkg/encoders/event/event_test.go b/pkg/encoders/event/event_test.go index 1b67ff1..8a3571c 100644 --- a/pkg/encoders/event/event_test.go +++ b/pkg/encoders/event/event_test.go @@ -6,16 +6,16 @@ import ( "testing" "time" - "encoders.orly/event/examples" - "encoders.orly/hex" - "encoders.orly/json" - "encoders.orly/tag" "lol.mleku.dev/chk" "lol.mleku.dev/log" "lukechampine.com/frand" - "utils.orly" - "utils.orly/bufpool" - "utils.orly/units" + "next.orly.dev/pkg/encoders/event/examples" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/json" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" + "next.orly.dev/pkg/utils/units" ) func TestMarshalJSONUnmarshalJSON(t *testing.T) { diff --git a/pkg/encoders/event/signatures.go b/pkg/encoders/event/signatures.go index 19fdd85..9fb5fc3 100644 --- a/pkg/encoders/event/signatures.go +++ b/pkg/encoders/event/signatures.go @@ -1,12 +1,12 @@ package event import ( - "crypto.orly/p256k" - "interfaces.orly/signer" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" "lol.mleku.dev/log" - "utils.orly" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/interfaces/signer" + "next.orly.dev/pkg/utils" ) // Sign the event using the signer.I. Uses github.com/bitcoin-core/secp256k1 if diff --git a/pkg/encoders/filter/filter.go b/pkg/encoders/filter/filter.go index 1502fd0..16f27e0 100644 --- a/pkg/encoders/filter/filter.go +++ b/pkg/encoders/filter/filter.go @@ -4,17 +4,17 @@ import ( "bytes" "sort" - "crypto.orly/ec/schnorr" - "crypto.orly/sha256" - "encoders.orly/event" - "encoders.orly/ints" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/text" - "encoders.orly/timestamp" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly/pointers" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/text" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils/pointers" ) // F is the primary query form for requesting events from a nostr relay. diff --git a/pkg/encoders/filter/filter_test.go b/pkg/encoders/filter/filter_test.go index 2f9aee3..c019ac6 100644 --- a/pkg/encoders/filter/filter_test.go +++ b/pkg/encoders/filter/filter_test.go @@ -4,7 +4,7 @@ import ( "testing" "lol.mleku.dev/chk" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestT_MarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/filter/filters.go b/pkg/encoders/filter/filters.go index b8e28c2..fb08d26 100644 --- a/pkg/encoders/filter/filters.go +++ b/pkg/encoders/filter/filters.go @@ -1,12 +1,17 @@ package filter import ( - "encoders.orly/event" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/encoders/event" ) type S []*F +func NewS(ff ...*F) *S { + s := S(ff) + return &s +} + // Match checks if a set of filters.T matches on an event.F. func (s *S) Match(event *event.E) bool { for _, f := range *s { @@ -19,11 +24,14 @@ func (s *S) Match(event *event.E) bool { // Marshal encodes a slice of filters as a JSON array of objects. // It appends the result to dst and returns the resulting slice. -func (s S) Marshal(dst []byte) (b []byte) { +func (s *S) Marshal(dst []byte) (b []byte) { + if s == nil { + panic("nil filter slice") + } b = dst b = append(b, '[') first := false - for _, f := range s { + for _, f := range *s { if f == nil { continue } @@ -82,3 +90,11 @@ func (s *S) Unmarshal(b []byte) (r []byte, err error) { return } } +func (s *S) MatchIgnoringTimestampConstraints(ev *event.E) bool { + for _, ff := range *s { + if ff.MatchesIgnoringTimestampConstraints(ev) { + return true + } + } + return false +} diff --git a/pkg/encoders/filter/gen.go b/pkg/encoders/filter/gen.go index 7c39db6..26bc7aa 100644 --- a/pkg/encoders/filter/gen.go +++ b/pkg/encoders/filter/gen.go @@ -3,16 +3,16 @@ package filter import ( "math" - "crypto.orly/ec/schnorr" - "crypto.orly/ec/secp256k1" - "crypto.orly/sha256" - "encoders.orly/hex" - "encoders.orly/kind" - "encoders.orly/tag" - "encoders.orly/timestamp" "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly/values" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/crypto/ec/secp256k1" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils/values" ) // GenFilter is a testing tool to create random arbitrary filters for tests. diff --git a/pkg/encoders/go.mod b/pkg/encoders/go.mod deleted file mode 100644 index d9a5a25..0000000 --- a/pkg/encoders/go.mod +++ /dev/null @@ -1,35 +0,0 @@ -module encoders.orly - -go 1.25.0 - -require ( - crypto.orly v0.0.0-00010101000000-000000000000 - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b - interfaces.orly v0.0.0-00010101000000-000000000000 - lol.mleku.dev v1.0.2 - lukechampine.com/frand v1.5.1 - protocol.orly v0.0.0-00010101000000-000000000000 - utils.orly v0.0.0-00010101000000-000000000000 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/templexxx/cpu v0.0.1 // indirect - golang.org/x/sys v0.35.0 // indirect -) - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) diff --git a/pkg/encoders/go.sum b/pkg/encoders/go.sum deleted file mode 100644 index cd95424..0000000 --- a/pkg/encoders/go.sum +++ /dev/null @@ -1,23 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b/go.mod h1:7rwmCH0wC2fQvNEvPZ3sKXukhyCTyiaZ5VTZMQYpZKQ= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= -lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= -lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= diff --git a/pkg/encoders/kind/kind.go b/pkg/encoders/kind/kind.go index efe3f15..d3c043c 100644 --- a/pkg/encoders/kind/kind.go +++ b/pkg/encoders/kind/kind.go @@ -6,9 +6,9 @@ package kind import ( "sync" - "encoders.orly/ints" "golang.org/x/exp/constraints" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/ints" ) // K - which will be externally referenced as kind.K is the event type in the diff --git a/pkg/encoders/kind/kinds.go b/pkg/encoders/kind/kinds.go index 33c7cd5..23efb22 100644 --- a/pkg/encoders/kind/kinds.go +++ b/pkg/encoders/kind/kinds.go @@ -3,9 +3,9 @@ package kind import ( - "encoders.orly/ints" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/encoders/ints" ) // S is an array of kind.K, used in filter.K and filter.S for searches. diff --git a/pkg/encoders/tag/atag/atag.go b/pkg/encoders/tag/atag/atag.go index fcf11c7..0be2f19 100644 --- a/pkg/encoders/tag/atag/atag.go +++ b/pkg/encoders/tag/atag/atag.go @@ -5,10 +5,10 @@ package atag import ( "bytes" - "encoders.orly/hex" - "encoders.orly/ints" - "encoders.orly/kind" "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/encoders/kind" ) // T is a data structure for what is found in an `a` tag: kind:pubkey:arbitrary data diff --git a/pkg/encoders/tag/atag/atag_test.go b/pkg/encoders/tag/atag/atag_test.go index 89549eb..981495b 100644 --- a/pkg/encoders/tag/atag/atag_test.go +++ b/pkg/encoders/tag/atag/atag_test.go @@ -4,13 +4,13 @@ import ( "math" "testing" - "crypto.orly/ec/schnorr" - "encoders.orly/hex" - "encoders.orly/kind" "lol.mleku.dev/chk" "lol.mleku.dev/log" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/crypto/ec/schnorr" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/utils" ) func TestT_Marshal_Unmarshal(t *testing.T) { diff --git a/pkg/encoders/tag/tag.go b/pkg/encoders/tag/tag.go index ceb32ce..8d6db65 100644 --- a/pkg/encoders/tag/tag.go +++ b/pkg/encoders/tag/tag.go @@ -6,10 +6,10 @@ package tag import ( "bytes" - "encoders.orly/text" "lol.mleku.dev/errorf" - utils "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/encoders/text" + utils "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) // The tag position meanings, so they are clear when reading. diff --git a/pkg/encoders/tag/tag_test.go b/pkg/encoders/tag/tag_test.go index 81b0c91..b5c9cc9 100644 --- a/pkg/encoders/tag/tag_test.go +++ b/pkg/encoders/tag/tag_test.go @@ -5,7 +5,7 @@ import ( "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/tag/tags.go b/pkg/encoders/tag/tags.go index 4e716d4..bb302f6 100644 --- a/pkg/encoders/tag/tags.go +++ b/pkg/encoders/tag/tags.go @@ -4,8 +4,8 @@ import ( "bytes" "lol.mleku.dev/chk" - "utils.orly" - "utils.orly/bufpool" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/bufpool" ) // S is a list of tag.T - which are lists of string elements with ordering and diff --git a/pkg/encoders/tag/tags_test.go b/pkg/encoders/tag/tags_test.go index 72a29f6..d15d644 100644 --- a/pkg/encoders/tag/tags_test.go +++ b/pkg/encoders/tag/tags_test.go @@ -5,7 +5,7 @@ import ( "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/utils" ) func TestSMarshalUnmarshal(t *testing.T) { diff --git a/pkg/encoders/text/escape_test.go b/pkg/encoders/text/escape_test.go index 9b046ed..5f5613b 100644 --- a/pkg/encoders/text/escape_test.go +++ b/pkg/encoders/text/escape_test.go @@ -3,9 +3,9 @@ package text import ( "testing" - "crypto.orly/sha256" "lol.mleku.dev/chk" "lukechampine.com/frand" + "next.orly.dev/pkg/crypto/sha256" ) func TestUnescapeByteString(t *testing.T) { diff --git a/pkg/encoders/text/helpers.go b/pkg/encoders/text/helpers.go index b34160e..ccfe395 100644 --- a/pkg/encoders/text/helpers.go +++ b/pkg/encoders/text/helpers.go @@ -3,11 +3,11 @@ package text import ( "io" - "encoders.orly/hex" "github.com/templexxx/xhex" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) // JSONKey generates the JSON format for an object key and terminates with the semicolon. diff --git a/pkg/encoders/text/helpers_test.go b/pkg/encoders/text/helpers_test.go index 55d088e..9bb15c9 100644 --- a/pkg/encoders/text/helpers_test.go +++ b/pkg/encoders/text/helpers_test.go @@ -3,11 +3,11 @@ package text import ( "testing" - "crypto.orly/sha256" - "encoders.orly/hex" "lol.mleku.dev/chk" "lukechampine.com/frand" - "utils.orly" + "next.orly.dev/pkg/crypto/sha256" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/utils" ) func TestUnmarshalHexArray(t *testing.T) { diff --git a/pkg/encoders/timestamp/timestamp.go b/pkg/encoders/timestamp/timestamp.go index cbe8dc1..81fb0d6 100644 --- a/pkg/encoders/timestamp/timestamp.go +++ b/pkg/encoders/timestamp/timestamp.go @@ -7,9 +7,9 @@ import ( "time" "unsafe" - "encoders.orly/ints" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" + "next.orly.dev/pkg/encoders/ints" ) // T is a convenience type for UNIX 64 bit timestamps of 1 second diff --git a/pkg/interfaces/acl/acl.go b/pkg/interfaces/acl/acl.go index 25d9748..3b6f409 100644 --- a/pkg/interfaces/acl/acl.go +++ b/pkg/interfaces/acl/acl.go @@ -2,7 +2,7 @@ package acl import ( - "interfaces.orly/typer" + "next.orly.dev/pkg/interfaces/typer" ) const ( diff --git a/pkg/interfaces/go.mod b/pkg/interfaces/go.mod deleted file mode 100644 index 5d08b05..0000000 --- a/pkg/interfaces/go.mod +++ /dev/null @@ -1,38 +0,0 @@ -module interfaces.orly - -go 1.25.0 - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) - -require ( - database.orly v0.0.0-00010101000000-000000000000 - encoders.orly v0.0.0-00010101000000-000000000000 - next.orly.dev v0.0.0-00010101000000-000000000000 -) - -require ( - crypto.orly v0.0.0-00010101000000-000000000000 // indirect - github.com/adrg/xdg v0.5.3 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/templexxx/cpu v0.0.1 // indirect - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b // indirect - go-simpler.org/env v0.12.0 // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect - golang.org/x/sys v0.35.0 // indirect - lol.mleku.dev v1.0.2 // indirect - lukechampine.com/frand v1.5.1 // indirect - utils.orly v0.0.0-00010101000000-000000000000 // indirect -) diff --git a/pkg/interfaces/go.sum b/pkg/interfaces/go.sum deleted file mode 100644 index d032de7..0000000 --- a/pkg/interfaces/go.sum +++ /dev/null @@ -1,33 +0,0 @@ -github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= -github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b/go.mod h1:7rwmCH0wC2fQvNEvPZ3sKXukhyCTyiaZ5VTZMQYpZKQ= -go-simpler.org/env v0.12.0 h1:kt/lBts0J1kjWJAnB740goNdvwNxt5emhYngL0Fzufs= -go-simpler.org/env v0.12.0/go.mod h1:cc/5Md9JCUM7LVLtN0HYjPTDcI3Q8TDaPlNTAlDU+WI= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= -lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= -lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= diff --git a/pkg/interfaces/publisher/publisher.go b/pkg/interfaces/publisher/publisher.go index 1d38507..261adfd 100644 --- a/pkg/interfaces/publisher/publisher.go +++ b/pkg/interfaces/publisher/publisher.go @@ -1,8 +1,8 @@ package publisher import ( - "encoders.orly/event" - "interfaces.orly/typer" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/interfaces/typer" ) type I interface { diff --git a/pkg/interfaces/store/alias.go b/pkg/interfaces/store/alias.go index 26fa293..bc1a7f0 100644 --- a/pkg/interfaces/store/alias.go +++ b/pkg/interfaces/store/alias.go @@ -3,7 +3,7 @@ package store import ( "net/http" - "encoders.orly/envelopes/okenvelope" + "next.orly.dev/pkg/encoders/envelopes/okenvelope" ) type Responder = http.ResponseWriter diff --git a/pkg/interfaces/store/store_interface.go b/pkg/interfaces/store/store_interface.go index 30406d5..a04eae6 100644 --- a/pkg/interfaces/store/store_interface.go +++ b/pkg/interfaces/store/store_interface.go @@ -10,11 +10,11 @@ import ( "context" "io" - "database.orly/indexes/types" - "encoders.orly/event" - "encoders.orly/filter" - "encoders.orly/tag" "next.orly.dev/app/config" + "next.orly.dev/pkg/database/indexes/types" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/tag" ) // I am a type for a persistence layer for nostr events handled by a relay. diff --git a/pkg/protocol/auth/nip42.go b/pkg/protocol/auth/nip42.go index 105bc6a..8cdaf6c 100644 --- a/pkg/protocol/auth/nip42.go +++ b/pkg/protocol/auth/nip42.go @@ -7,12 +7,12 @@ import ( "strings" "time" - "encoders.orly/event" - "encoders.orly/kind" - "encoders.orly/tag" "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/utils" ) // GenerateChallenge creates a reasonable, 16-byte base64 challenge string diff --git a/pkg/protocol/auth/nip42_test.go b/pkg/protocol/auth/nip42_test.go index ca616c3..f74bcba 100644 --- a/pkg/protocol/auth/nip42_test.go +++ b/pkg/protocol/auth/nip42_test.go @@ -3,9 +3,9 @@ package auth import ( "testing" - "crypto.orly/p256k" "lol.mleku.dev/chk" "lol.mleku.dev/log" + "next.orly.dev/pkg/crypto/p256k" ) func TestCreateUnsigned(t *testing.T) { diff --git a/pkg/protocol/go.mod b/pkg/protocol/go.mod deleted file mode 100644 index a75d60b..0000000 --- a/pkg/protocol/go.mod +++ /dev/null @@ -1,34 +0,0 @@ -module protocol.orly - -go 1.25.0 - -require ( - crypto.orly v0.0.0-00010101000000-000000000000 - encoders.orly v0.0.0-00010101000000-000000000000 - interfaces.orly v0.0.0-00010101000000-000000000000 - lol.mleku.dev v1.0.2 - utils.orly v0.0.0-00010101000000-000000000000 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/templexxx/cpu v0.0.1 // indirect - github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect - golang.org/x/sys v0.35.0 // indirect -) - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) diff --git a/pkg/protocol/go.sum b/pkg/protocol/go.sum deleted file mode 100644 index cd95424..0000000 --- a/pkg/protocol/go.sum +++ /dev/null @@ -1,23 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/templexxx/cpu v0.0.1 h1:hY4WdLOgKdc8y13EYklu9OUTXik80BkxHoWvTO6MQQY= -github.com/templexxx/cpu v0.0.1/go.mod h1:w7Tb+7qgcAlIyX4NhLuDKt78AHA5SzPmq0Wj6HiEnnk= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b h1:XeDLE6c9mzHpdv3Wb1+pWBaWv/BlHK0ZYIu/KaL6eHg= -github.com/templexxx/xhex v0.0.0-20200614015412-aed53437177b/go.mod h1:7rwmCH0wC2fQvNEvPZ3sKXukhyCTyiaZ5VTZMQYpZKQ= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= -lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= -lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= diff --git a/pkg/protocol/publish/publisher.go b/pkg/protocol/publish/publisher.go index 9170f4a..5e7906b 100644 --- a/pkg/protocol/publish/publisher.go +++ b/pkg/protocol/publish/publisher.go @@ -1,9 +1,9 @@ package publish import ( - "encoders.orly/event" - "interfaces.orly/publisher" - "interfaces.orly/typer" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/interfaces/publisher" + "next.orly.dev/pkg/interfaces/typer" ) // S is the control structure for the subscription management scheme. diff --git a/pkg/protocol/relayinfo/fetch.go b/pkg/protocol/relayinfo/fetch.go index 97d6816..7af9d3b 100644 --- a/pkg/protocol/relayinfo/fetch.go +++ b/pkg/protocol/relayinfo/fetch.go @@ -9,7 +9,7 @@ import ( "lol.mleku.dev/chk" "lol.mleku.dev/errorf" - "utils.orly/normalize" + "next.orly.dev/pkg/utils/normalize" ) // Fetch fetches the NIP-11 Info. diff --git a/pkg/protocol/relayinfo/types.go b/pkg/protocol/relayinfo/types.go index 13283fc..0670602 100644 --- a/pkg/protocol/relayinfo/types.go +++ b/pkg/protocol/relayinfo/types.go @@ -7,11 +7,11 @@ import ( "sort" "sync" - "encoders.orly/kind" - "encoders.orly/timestamp" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly/number" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/timestamp" + "next.orly.dev/pkg/utils/number" ) // NIP is a number and description of a nostr "improvement" possibility. diff --git a/pkg/protocol/ws/client.go b/pkg/protocol/ws/client.go new file mode 100644 index 0000000..bf375dd --- /dev/null +++ b/pkg/protocol/ws/client.go @@ -0,0 +1,629 @@ +package ws + +import ( + "bytes" + "context" + "crypto/tls" + "errors" + "fmt" + "net/http" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/puzpuzpuz/xsync/v3" + "lol.mleku.dev/chk" + "lol.mleku.dev/log" + "next.orly.dev/pkg/encoders/envelopes" + "next.orly.dev/pkg/encoders/envelopes/authenvelope" + "next.orly.dev/pkg/encoders/envelopes/closedenvelope" + "next.orly.dev/pkg/encoders/envelopes/eoseenvelope" + "next.orly.dev/pkg/encoders/envelopes/eventenvelope" + "next.orly.dev/pkg/encoders/envelopes/noticeenvelope" + "next.orly.dev/pkg/encoders/envelopes/okenvelope" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/interfaces/codec" + "next.orly.dev/pkg/interfaces/signer" + "next.orly.dev/pkg/utils/normalize" +) + +var subscriptionIDCounter atomic.Int64 + +// Client represents a connection to a Nostr relay. +type Client struct { + closeMutex sync.Mutex + + URL string + requestHeader http.Header // e.g. for origin header + + Connection *Connection + Subscriptions *xsync.MapOf[string, *Subscription] + + ConnectionError error + connectionContext context.Context // will be canceled when the connection closes + connectionContextCancel context.CancelCauseFunc + + challenge []byte // NIP-42 challenge, we only keep the last + notices chan []byte // NIP-01 NOTICEs + customHandler func(string) // nonstandard unparseable messages + okCallbacks *xsync.MapOf[string, func(bool, string)] + writeQueue chan writeRequest + subscriptionChannelCloseQueue chan []byte + + // custom things that aren't often used + // + AssumeValid bool // this will skip verifying signatures for events received from this relay +} + +type writeRequest struct { + msg []byte + answer chan error +} + +// NewRelay returns a new relay. It takes a context that, when canceled, will close the relay connection. +func NewRelay(ctx context.Context, url string, opts ...RelayOption) *Client { + ctx, cancel := context.WithCancelCause(ctx) + r := &Client{ + URL: string(normalize.URL(url)), + connectionContext: ctx, + connectionContextCancel: cancel, + Subscriptions: xsync.NewMapOf[string, *Subscription](), + okCallbacks: xsync.NewMapOf[string, func( + bool, string, + )](), + writeQueue: make(chan writeRequest), + subscriptionChannelCloseQueue: make(chan []byte), + requestHeader: nil, + } + + for _, opt := range opts { + opt.ApplyRelayOption(r) + } + + return r +} + +// RelayConnect returns a relay object connected to url. +// +// The given subscription is only used during the connection phase. Once successfully connected, cancelling ctx has no effect. +// +// The ongoing relay connection uses a background context. To close the connection, call r.Close(). +// If you need fine grained long-term connection contexts, use NewRelay() instead. +func RelayConnect(ctx context.Context, url string, opts ...RelayOption) ( + *Client, error, +) { + r := NewRelay(context.Background(), url, opts...) + err := r.Connect(ctx) + return r, err +} + +// RelayOption is the type of the argument passed when instantiating relay connections. +type RelayOption interface { + ApplyRelayOption(*Client) +} + +var ( + _ RelayOption = (WithCustomHandler)(nil) + _ RelayOption = (WithRequestHeader)(nil) +) + +// WithCustomHandler must be a function that handles any relay message that couldn't be +// parsed as a standard envelope. +type WithCustomHandler func(data string) + +func (ch WithCustomHandler) ApplyRelayOption(r *Client) { + r.customHandler = ch +} + +// WithRequestHeader sets the HTTP request header of the websocket preflight request. +type WithRequestHeader http.Header + +func (ch WithRequestHeader) ApplyRelayOption(r *Client) { + r.requestHeader = http.Header(ch) +} + +// String just returns the relay URL. +func (r *Client) String() string { + return r.URL +} + +// Context retrieves the context that is associated with this relay connection. +// It will be closed when the relay is disconnected. +func (r *Client) Context() context.Context { return r.connectionContext } + +// IsConnected returns true if the connection to this relay seems to be active. +func (r *Client) IsConnected() bool { return r.connectionContext.Err() == nil } + +// Connect tries to establish a websocket connection to r.URL. +// If the context expires before the connection is complete, an error is returned. +// Once successfully connected, context expiration has no effect: call r.Close +// to close the connection. +// +// The given context here is only used during the connection phase. The long-living +// relay connection will be based on the context given to NewRelay(). +func (r *Client) Connect(ctx context.Context) error { + return r.ConnectWithTLS(ctx, nil) +} + +func extractSubID(jsonStr string) string { + // look for "EVENT" pattern + start := strings.Index(jsonStr, `"EVENT"`) + if start == -1 { + return "" + } + + // move to the next quote + offset := strings.Index(jsonStr[start+7:], `"`) + if offset == -1 { + return "" + } + + start += 7 + offset + 1 + + // find the ending quote + end := strings.Index(jsonStr[start:], `"`) + + // get the contents + return jsonStr[start : start+end] +} + +func subIdToSerial(subId string) int64 { + n := strings.Index(subId, ":") + if n < 0 || n > len(subId) { + return -1 + } + serialId, _ := strconv.ParseInt(subId[0:n], 10, 64) + return serialId +} + +// ConnectWithTLS is like Connect(), but takes a special tls.Config if you need that. +func (r *Client) ConnectWithTLS( + ctx context.Context, tlsConfig *tls.Config, +) error { + if r.connectionContext == nil || r.Subscriptions == nil { + return fmt.Errorf("relay must be initialized with a call to NewRelay()") + } + + if r.URL == "" { + return fmt.Errorf("invalid relay URL '%s'", r.URL) + } + + if _, ok := ctx.Deadline(); !ok { + // if no timeout is set, force it to 7 seconds + var cancel context.CancelFunc + ctx, cancel = context.WithTimeoutCause( + ctx, 7*time.Second, errors.New("connection took too long"), + ) + defer cancel() + } + + conn, err := NewConnection(ctx, r.URL, r.requestHeader, tlsConfig) + if err != nil { + return fmt.Errorf("error opening websocket to '%s': %w", r.URL, err) + } + r.Connection = conn + + // ping every 29 seconds + ticker := time.NewTicker(29 * time.Second) + + // queue all write operations here so we don't do mutex spaghetti + go func() { + var err error + for { + select { + case <-r.connectionContext.Done(): + ticker.Stop() + r.Connection = nil + + for _, sub := range r.Subscriptions.Range { + sub.unsub( + fmt.Errorf( + "relay connection closed: %w / %w", + context.Cause(r.connectionContext), + r.ConnectionError, + ), + ) + } + return + + case <-ticker.C: + err = r.Connection.Ping(r.connectionContext) + if err != nil && !strings.Contains( + err.Error(), "failed to wait for pong", + ) { + log.I.F( + "{%s} error writing ping: %v; closing websocket", r.URL, + err, + ) + r.Close() // this should trigger a context cancelation + return + } + + case wr := <-r.writeQueue: + // all write requests will go through this to prevent races + log.D.F("{%s} sending %v\n", r.URL, string(wr.msg)) + if err = r.Connection.WriteMessage( + r.connectionContext, wr.msg, + ); err != nil { + wr.answer <- err + } + close(wr.answer) + } + } + }() + + // general message reader loop + go func() { + + for { + buf := new(bytes.Buffer) + for { + buf.Reset() + if err := conn.ReadMessage( + r.connectionContext, buf, + ); err != nil { + r.ConnectionError = err + r.Close() + return + } + message := buf.Bytes() + var t string + if t, message, err = envelopes.Identify(message); chk.E(err) { + continue + } + switch t { + case noticeenvelope.L: + env := noticeenvelope.New() + if env, message, err = noticeenvelope.Parse(message); chk.E(err) { + continue + } + // see WithNoticeHandler + if r.notices != nil { + r.notices <- env.Message + } else { + log.E.F("NOTICE from %s: '%s'\n", r.URL, env.Message) + } + case authenvelope.L: + env := authenvelope.NewChallenge() + if env, message, err = authenvelope.ParseChallenge(message); chk.E(err) { + continue + } + if len(env.Challenge) == 0 { + continue + } + r.challenge = env.Challenge + case eventenvelope.L: + env := eventenvelope.NewResult() + if env, message, err = eventenvelope.ParseResult(message); chk.E(err) { + continue + } + if len(env.Subscription) == 0 { + continue + } + if sub, ok := r.Subscriptions.Load(string(env.Subscription)); !ok { + log.D.F( + "{%s} no subscription with id '%s'\n", r.URL, + env.Subscription, + ) + continue + } else { + // check if the event matches the desired filter, ignore otherwise + if !sub.Filters.Match(env.Event) { + // log.D.F( + // "{%s} filter does not match: %v ~ %v\n", r.URL, + // sub.Filters, env.Event, + // ) + continue + } + // check signature, ignore invalid, except from trusted (AssumeValid) relays + if !r.AssumeValid { + if ok, err = env.Event.Verify(); !ok { + log.E.F( + "{%s} bad signature on %s\n", r.URL, + env.Event, + ) + continue + } + } + // dispatch this to the internal .events channel of the subscription + sub.dispatchEvent(env.Event) + } + case eoseenvelope.L: + env := eoseenvelope.New() + if env, message, err = eoseenvelope.Parse(message); chk.E(err) { + continue + } + if subscription, ok := r.Subscriptions.Load(string(env.Subscription)); ok { + subscription.dispatchEose() + } + case closedenvelope.L: + env := closedenvelope.New() + if env, message, err = closedenvelope.Parse(message); chk.E(err) { + continue + } + if subscription, ok := r.Subscriptions.Load(string(env.Subscription)); ok { + subscription.handleClosed(env.ReasonString()) + } + case okenvelope.L: + env := okenvelope.New() + if env, message, err = okenvelope.Parse(message); chk.E(err) { + continue + } + if okCallback, exist := r.okCallbacks.Load(string(env.EventID)); exist { + okCallback(env.OK, env.ReasonString()) + } else { + log.I.F( + "{%s} got an unexpected OK message for event %s", + r.URL, + env.EventID, + ) + } + } + } + } + }() + + return nil +} + +// Write queues an arbitrary message to be sent to the relay. +func (r *Client) Write(msg []byte) <-chan error { + ch := make(chan error) + select { + case r.writeQueue <- writeRequest{msg: msg, answer: ch}: + case <-r.connectionContext.Done(): + go func() { ch <- fmt.Errorf("connection closed") }() + } + return ch +} + +// Publish sends an "EVENT" command to the relay r as in NIP-01 and waits for an OK response. +func (r *Client) Publish(ctx context.Context, ev *event.E) error { + return r.publish( + ctx, hex.Enc(ev.ID), eventenvelope.NewSubmissionWith(ev), + ) +} + +// Auth sends an "AUTH" command client->relay as in NIP-42 and waits for an OK response. +// +// You don't have to build the AUTH event yourself, this function takes a function to which the +// event that must be signed will be passed, so it's only necessary to sign that. +func (r *Client) Auth( + ctx context.Context, sign signer.I, +) (err error) { + authEvent := &event.E{ + CreatedAt: time.Now().Unix(), + Kind: kind.ClientAuthentication.K, + Tags: tag.NewS( + tag.NewFromAny("relay", r.URL), + tag.NewFromAny("challenge", r.challenge), + ), + Content: nil, + } + if err = authEvent.Sign(sign); err != nil { + return fmt.Errorf("error signing auth event: %w", err) + } + + return r.publish( + ctx, hex.Enc(authEvent.ID), authenvelope.NewResponseWith(authEvent), + ) +} + +func (r *Client) publish( + ctx context.Context, id string, env codec.Envelope, +) error { + var err error + var cancel context.CancelFunc + + if _, ok := ctx.Deadline(); !ok { + // if no timeout is set, force it to 7 seconds + ctx, cancel = context.WithTimeoutCause( + ctx, 7*time.Second, fmt.Errorf("given up waiting for an OK"), + ) + defer cancel() + } else { + // otherwise make the context cancellable so we can stop everything upon receiving an "OK" + ctx, cancel = context.WithCancel(ctx) + defer cancel() + } + + // listen for an OK callback + gotOk := false + r.okCallbacks.Store( + id, func(ok bool, reason string) { + gotOk = true + if !ok { + err = fmt.Errorf("msg: %s", reason) + } + cancel() + }, + ) + defer r.okCallbacks.Delete(id) + + // publish event + envb := env.Marshal(nil) + if err = <-r.Write(envb); err != nil { + return err + } + + for { + select { + case <-ctx.Done(): + // this will be called when we get an OK or when the context has been canceled + if gotOk { + return err + } + return ctx.Err() + case <-r.connectionContext.Done(): + // this is caused when we lose connectivity + return err + } + } +} + +// Subscribe sends a "REQ" command to the relay r as in NIP-01. +// Events are returned through the channel sub.Events. +// The subscription is closed when context ctx is cancelled ("CLOSE" in NIP-01). +// +// Remember to cancel subscriptions, either by calling `.Unsub()` on them or ensuring their `context.Context` will be canceled at some point. +// Failure to do that will result in a huge number of halted goroutines being created. +func (r *Client) Subscribe( + ctx context.Context, ff *filter.S, opts ...SubscriptionOption, +) (*Subscription, error) { + sub := r.PrepareSubscription(ctx, ff, opts...) + + if r.Connection == nil { + return nil, fmt.Errorf("not connected to %s", r.URL) + } + + if err := sub.Fire(); err != nil { + return nil, fmt.Errorf( + "couldn't subscribe to %v at %s: %w", ff, r.URL, err, + ) + } + + return sub, nil +} + +// PrepareSubscription creates a subscription, but doesn't fire it. +// +// Remember to cancel subscriptions, either by calling `.Unsub()` on them or ensuring their `context.Context` will be canceled at some point. +// Failure to do that will result in a huge number of halted goroutines being created. +func (r *Client) PrepareSubscription( + ctx context.Context, ff *filter.S, opts ...SubscriptionOption, +) (sub *Subscription) { + current := subscriptionIDCounter.Add(1) + ctx, cancel := context.WithCancelCause(ctx) + sub = &Subscription{ + Client: r, + Context: ctx, + cancel: cancel, + counter: current, + Events: make(event.C), + EndOfStoredEvents: make(chan struct{}, 1), + ClosedReason: make(chan string, 1), + Filters: ff, + match: ff.Match, + } + label := "" + for _, opt := range opts { + switch o := opt.(type) { + case WithLabel: + label = string(o) + case WithCheckDuplicate: + sub.checkDuplicate = o + case WithCheckDuplicateReplaceable: + sub.checkDuplicateReplaceable = o + } + } + // subscription id computation + buf := subIdPool.Get().([]byte)[:0] + buf = strconv.AppendInt(buf, sub.counter, 10) + buf = append(buf, ':') + buf = append(buf, label...) + defer subIdPool.Put(buf) + sub.id = buf + r.Subscriptions.Store(string(buf), sub) + // start handling events, eose, unsub etc: + go sub.start() + return sub +} + +// QueryEvents subscribes to events matching the given filter and returns a channel of events. +// +// In most cases it's better to use SimplePool instead of this method. +func (r *Client) QueryEvents( + ctx context.Context, f *filter.F, opts ...SubscriptionOption, +) ( + evc event.C, err error, +) { + var sub *Subscription + if sub, err = r.Subscribe(ctx, filter.NewS(f), opts...); chk.E(err) { + return + } + go func() { + for { + select { + case <-sub.ClosedReason: + case <-sub.EndOfStoredEvents: + case <-ctx.Done(): + case <-r.Context().Done(): + } + sub.unsub(errors.New("QueryEvents() ended")) + return + } + }() + evc = sub.Events + return +} + +// QuerySync subscribes to events matching the given filter and returns a slice of events. +// This method blocks until all events are received or the context is canceled. +// +// In most cases it's better to use SimplePool instead of this method. +func (r *Client) QuerySync( + ctx context.Context, ff *filter.F, opts ...SubscriptionOption, +) ( + []*event.E, error, +) { + if _, ok := ctx.Deadline(); !ok { + // if no timeout is set, force it to 7 seconds + var cancel context.CancelFunc + ctx, cancel = context.WithTimeoutCause( + ctx, 7*time.Second, errors.New("QuerySync() took too long"), + ) + defer cancel() + } + var lim int + if ff.Limit != nil { + lim = int(*ff.Limit) + } + events := make([]*event.E, 0, max(lim, 250)) + ch, err := r.QueryEvents(ctx, ff, opts...) + if err != nil { + return nil, err + } + + for evt := range ch { + events = append(events, evt) + } + + return events, nil +} + +// Close closes the relay connection. +func (r *Client) Close() error { + return r.close(errors.New("Close() called")) +} + +func (r *Client) close(reason error) error { + r.closeMutex.Lock() + defer r.closeMutex.Unlock() + + if r.connectionContextCancel == nil { + return fmt.Errorf("relay already closed") + } + r.connectionContextCancel(reason) + r.connectionContextCancel = nil + + if r.Connection == nil { + return fmt.Errorf("relay not connected") + } + + err := r.Connection.Close() + if err != nil { + return err + } + + return nil +} + +var subIdPool = sync.Pool{ + New: func() any { return make([]byte, 0, 15) }, +} diff --git a/pkg/protocol/ws/client_test.go b/pkg/protocol/ws/client_test.go new file mode 100644 index 0000000..5a89780 --- /dev/null +++ b/pkg/protocol/ws/client_test.go @@ -0,0 +1,277 @@ +//go:build !js + +package ws + +import ( + "context" + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "sync" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "golang.org/x/net/websocket" + "lol.mleku.dev/chk" + "next.orly.dev/pkg/crypto/p256k" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/hex" + "next.orly.dev/pkg/encoders/kind" + "next.orly.dev/pkg/encoders/tag" + "next.orly.dev/pkg/utils" + "next.orly.dev/pkg/utils/normalize" +) + +func TestPublish(t *testing.T) { + // test note to be sent over websocket + priv, pub := makeKeyPair(t) + textNote := &event.E{ + Kind: kind.TextNote.K, + Content: []byte("hello"), + CreatedAt: 1672068534, // random fixed timestamp + Tags: tag.NewS(tag.NewFromAny("foo", "bar")), + Pubkey: pub, + } + sign := &p256k.Signer{} + var err error + if err = sign.InitSec(priv); chk.E(err) { + } + err = textNote.Sign(sign) + assert.NoError(t, err) + + // fake relay server + var mu sync.Mutex // guards published to satisfy go test -race + var published bool + ws := newWebsocketServer( + func(conn *websocket.Conn) { + mu.Lock() + published = true + mu.Unlock() + // verify the client sent exactly the textNote + var raw []json.RawMessage + err := websocket.JSON.Receive(conn, &raw) + assert.NoError(t, err) + + event := parseEventMessage(t, raw) + assert.True( + t, utils.FastEqual(event.Serialize(), textNote.Serialize()), + ) + + // send back an ok nip-20 command result + res := []any{"OK", hex.Enc(textNote.ID), true, ""} + err = websocket.JSON.Send(conn, res) + assert.NoError(t, err) + }, + ) + defer ws.Close() + + // connect a client and send the text note + rl := mustRelayConnect(t, ws.URL) + err = rl.Publish(context.Background(), textNote) + assert.NoError(t, err) + + assert.True(t, published, "fake relay server saw no event") +} + +// func TestPublishBlocked(t *testing.T) { +// // test note to be sent over websocket +// textNote := &event.E{ +// Kind: kind.TextNote, Content: []byte("hello"), +// CreatedAt: timestamp.Now(), +// } +// textNote.ID = textNote.GetIDBytes() +// +// // fake relay server +// ws := newWebsocketServer( +// func(conn *websocket.Conn) { +// // discard received message; not interested +// var raw []json.RawMessage +// err := websocket.JSON.Receive(conn, &raw) +// assert.NoError(t, err) +// +// // send back a not ok nip-20 command result +// res := []any{"OK", textNote.IdString(), false, "blocked"} +// websocket.JSON.Send(conn, res) +// }, +// ) +// defer ws.Close() +// +// // connect a client and send a text note +// rl := mustRelayConnect(t, ws.URL) +// err := rl.Publish(context.Background(), textNote) +// assert.Error(t, err) +// } + +func TestPublishWriteFailed(t *testing.T) { + // test note to be sent over websocket + textNote := &event.E{ + Kind: kind.TextNote.K, + Content: []byte("hello"), + CreatedAt: time.Now().Unix(), + } + textNote.ID = textNote.GetIDBytes() + // fake relay server + ws := newWebsocketServer( + func(conn *websocket.Conn) { + // reject receive - force send error + conn.Close() + }, + ) + defer ws.Close() + // connect a client and send a text note + rl := mustRelayConnect(t, ws.URL) + // Force brief period of time so that publish always fails on closed socket. + time.Sleep(1 * time.Millisecond) + err := rl.Publish(context.Background(), textNote) + assert.Error(t, err) +} + +func TestConnectContext(t *testing.T) { + // fake relay server + var mu sync.Mutex // guards connected to satisfy go test -race + var connected bool + ws := newWebsocketServer( + func(conn *websocket.Conn) { + mu.Lock() + connected = true + mu.Unlock() + io.ReadAll(conn) // discard all input + }, + ) + defer ws.Close() + + // relay client + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + r, err := RelayConnect(ctx, ws.URL) + assert.NoError(t, err) + + defer r.Close() + + mu.Lock() + defer mu.Unlock() + assert.True(t, connected, "fake relay server saw no client connect") +} + +func TestConnectContextCanceled(t *testing.T) { + // fake relay server + ws := newWebsocketServer(discardingHandler) + defer ws.Close() + + // relay client + ctx, cancel := context.WithCancel(context.Background()) + cancel() // make ctx expired + _, err := RelayConnect(ctx, ws.URL) + assert.ErrorIs(t, err, context.Canceled) +} + +func TestConnectWithOrigin(t *testing.T) { + // fake relay server + // default handler requires origin golang.org/x/net/websocket + ws := httptest.NewServer(websocket.Handler(discardingHandler)) + defer ws.Close() + + // relay client + r := NewRelay( + context.Background(), string(normalize.URL(ws.URL)), + WithRequestHeader(http.Header{"origin": {"https://example.com"}}), + ) + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + err := r.Connect(ctx) + assert.NoError(t, err) +} + +func discardingHandler(conn *websocket.Conn) { + io.ReadAll(conn) // discard all input +} + +func newWebsocketServer(handler func(*websocket.Conn)) *httptest.Server { + return httptest.NewServer( + &websocket.Server{ + Handshake: anyOriginHandshake, + Handler: handler, + }, + ) +} + +// anyOriginHandshake is an alternative to default in golang.org/x/net/websocket +// which checks for origin. nostr client sends no origin and it makes no difference +// for the tests here anyway. +var anyOriginHandshake = func(conf *websocket.Config, r *http.Request) error { + return nil +} + +func makeKeyPair(t *testing.T) (sec, pub []byte) { + t.Helper() + sign := &p256k.Signer{} + var err error + if err = sign.Generate(); chk.E(err) { + return + } + sec = sign.Sec() + pub = sign.Pub() + assert.NoError(t, err) + + return +} + +func mustRelayConnect(t *testing.T, url string) *Client { + t.Helper() + + rl, err := RelayConnect(context.Background(), url) + require.NoError(t, err) + + return rl +} + +func parseEventMessage(t *testing.T, raw []json.RawMessage) *event.E { + t.Helper() + + assert.Condition( + t, func() (success bool) { + return len(raw) >= 2 + }, + ) + + var typ string + err := json.Unmarshal(raw[0], &typ) + assert.NoError(t, err) + assert.Equal(t, "EVENT", typ) + + event := &event.E{} + _, err = event.Unmarshal(raw[1]) + require.NoError(t, err) + + return event +} + +func parseSubscriptionMessage( + t *testing.T, raw []json.RawMessage, +) (subid string, ff *filter.S) { + t.Helper() + + assert.Greater(t, len(raw), 3) + + var typ string + err := json.Unmarshal(raw[0], &typ) + + assert.NoError(t, err) + assert.Equal(t, "REQ", typ) + + var id string + err = json.Unmarshal(raw[1], &id) + assert.NoError(t, err) + ff = &filter.S{} + for _, b := range raw[2:] { + var f *filter.F + err = json.Unmarshal(b, &f) + assert.NoError(t, err) + *ff = append(*ff, f) + } + return id, ff +} diff --git a/pkg/protocol/ws/connection.go b/pkg/protocol/ws/connection.go new file mode 100644 index 0000000..20925a6 --- /dev/null +++ b/pkg/protocol/ws/connection.go @@ -0,0 +1,79 @@ +package ws + +import ( + "context" + "crypto/tls" + "errors" + "fmt" + "io" + "net/http" + "time" + + "lol.mleku.dev/errorf" + "next.orly.dev/pkg/utils/units" + + ws "github.com/coder/websocket" +) + +// Connection represents a websocket connection to a Nostr relay. +type Connection struct { + conn *ws.Conn +} + +// NewConnection creates a new websocket connection to a Nostr relay. +func NewConnection( + ctx context.Context, url string, reqHeader http.Header, + tlsConfig *tls.Config, +) (c *Connection, err error) { + var conn *ws.Conn + if conn, _, err = ws.Dial( + ctx, url, getConnectionOptions(reqHeader, tlsConfig), + ); err != nil { + return + } + conn.SetReadLimit(33 * units.Mb) + return &Connection{ + conn: conn, + }, nil +} + +// WriteMessage writes arbitrary bytes to the websocket connection. +func (c *Connection) WriteMessage( + ctx context.Context, data []byte, +) (err error) { + if err = c.conn.Write(ctx, ws.MessageText, data); err != nil { + err = errorf.E("failed to write message: %w", err) + return + } + return nil +} + +// ReadMessage reads arbitrary bytes from the websocket connection into the provided buffer. +func (c *Connection) ReadMessage( + ctx context.Context, buf io.Writer, +) (err error) { + var reader io.Reader + if _, reader, err = c.conn.Reader(ctx); err != nil { + err = fmt.Errorf("failed to get reader: %w", err) + return + } + if _, err = io.Copy(buf, reader); err != nil { + err = fmt.Errorf("failed to read message: %w", err) + return + } + return +} + +// Close closes the websocket connection. +func (c *Connection) Close() error { + return c.conn.Close(ws.StatusNormalClosure, "") +} + +// Ping sends a ping message to the websocket connection. +func (c *Connection) Ping(ctx context.Context) error { + ctx, cancel := context.WithTimeoutCause( + ctx, time.Millisecond*800, errors.New("ping took too long"), + ) + defer cancel() + return c.conn.Ping(ctx) +} diff --git a/pkg/protocol/ws/connection_options.go b/pkg/protocol/ws/connection_options.go new file mode 100644 index 0000000..ae187fe --- /dev/null +++ b/pkg/protocol/ws/connection_options.go @@ -0,0 +1,36 @@ +//go:build !js + +package ws + +import ( + "crypto/tls" + "net/http" + "net/textproto" + + ws "github.com/coder/websocket" +) + +var defaultConnectionOptions = &ws.DialOptions{ + CompressionMode: ws.CompressionContextTakeover, + HTTPHeader: http.Header{ + textproto.CanonicalMIMEHeaderKey("User-Agent"): {"github.com/nbd-wtf/go-nostr"}, + }, +} + +func getConnectionOptions( + requestHeader http.Header, tlsConfig *tls.Config, +) *ws.DialOptions { + if requestHeader == nil && tlsConfig == nil { + return defaultConnectionOptions + } + + return &ws.DialOptions{ + HTTPHeader: requestHeader, + CompressionMode: ws.CompressionContextTakeover, + HTTPClient: &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: tlsConfig, + }, + }, + } +} diff --git a/pkg/protocol/ws/subscription.go b/pkg/protocol/ws/subscription.go new file mode 100644 index 0000000..cfc4c65 --- /dev/null +++ b/pkg/protocol/ws/subscription.go @@ -0,0 +1,189 @@ +package ws + +import ( + "context" + "errors" + "fmt" + "sync" + "sync/atomic" + + "lol.mleku.dev/chk" + "next.orly.dev/pkg/encoders/envelopes/closeenvelope" + "next.orly.dev/pkg/encoders/envelopes/reqenvelope" + "next.orly.dev/pkg/encoders/event" + "next.orly.dev/pkg/encoders/filter" + "next.orly.dev/pkg/encoders/timestamp" +) + +type ReplaceableKey struct { + PubKey string + D string +} + +// Subscription represents a subscription to a relay. +type Subscription struct { + counter int64 + id []byte + + Client *Client + Filters *filter.S + + // the Events channel emits all EVENTs that come in a Subscription + // will be closed when the subscription ends + Events chan *event.E + mu sync.Mutex + + // the EndOfStoredEvents channel gets closed when an EOSE comes for that subscription + EndOfStoredEvents chan struct{} + + // the ClosedReason channel emits the reason when a CLOSED message is received + ClosedReason chan string + + // Context will be .Done() when the subscription ends + Context context.Context + + // if it is not nil, checkDuplicate will be called for every event received + // if it returns true that event will not be processed further. + checkDuplicate func(id string, relay string) bool + + // if it is not nil, checkDuplicateReplaceable will be called for every event received + // if it returns true that event will not be processed further. + checkDuplicateReplaceable func(rk ReplaceableKey, ts *timestamp.T) bool + + match func(*event.E) bool // this will be either Filters.Match or Filters.MatchIgnoringTimestampConstraints + live atomic.Bool + eosed atomic.Bool + cancel context.CancelCauseFunc + + // this keeps track of the events we've received before the EOSE that we must dispatch before + // closing the EndOfStoredEvents channel + storedwg sync.WaitGroup +} + +// SubscriptionOption is the type of the argument passed when instantiating relay connections. +// Some examples are WithLabel. +type SubscriptionOption interface { + IsSubscriptionOption() +} + +// WithLabel puts a label on the subscription (it is prepended to the automatic id) that is sent to relays. +type WithLabel string + +func (_ WithLabel) IsSubscriptionOption() {} + +// WithCheckDuplicate sets checkDuplicate on the subscription +type WithCheckDuplicate func(id, relay string) bool + +func (_ WithCheckDuplicate) IsSubscriptionOption() {} + +// WithCheckDuplicateReplaceable sets checkDuplicateReplaceable on the subscription +type WithCheckDuplicateReplaceable func(rk ReplaceableKey, ts *timestamp.T) bool + +func (_ WithCheckDuplicateReplaceable) IsSubscriptionOption() {} + +var ( + _ SubscriptionOption = (WithLabel)("") + _ SubscriptionOption = (WithCheckDuplicate)(nil) + _ SubscriptionOption = (WithCheckDuplicateReplaceable)(nil) +) + +func (sub *Subscription) start() { + <-sub.Context.Done() + // the subscription ends once the context is canceled (if not already) + sub.unsub(errors.New("context done on start()")) // this will set sub.live to false + // do this so we don't have the possibility of closing the Events channel and then trying to send to it + sub.mu.Lock() + close(sub.Events) + sub.mu.Unlock() +} + +// GetID returns the subscription ID. +func (sub *Subscription) GetID() string { return string(sub.id) } + +func (sub *Subscription) dispatchEvent(evt *event.E) { + added := false + if !sub.eosed.Load() { + sub.storedwg.Add(1) + added = true + } + go func() { + sub.mu.Lock() + defer sub.mu.Unlock() + + if sub.live.Load() { + select { + case sub.Events <- evt: + case <-sub.Context.Done(): + } + } + if added { + sub.storedwg.Done() + } + }() +} + +func (sub *Subscription) dispatchEose() { + if sub.eosed.CompareAndSwap(false, true) { + sub.match = sub.Filters.MatchIgnoringTimestampConstraints + go func() { + sub.storedwg.Wait() + sub.EndOfStoredEvents <- struct{}{} + }() + } +} + +// handleClosed handles the CLOSED message from a relay. +func (sub *Subscription) handleClosed(reason string) { + go func() { + sub.ClosedReason <- reason + sub.live.Store(false) // set this so we don't send an unnecessary CLOSE to the relay + sub.unsub(fmt.Errorf("CLOSED received: %s", reason)) + }() +} + +// 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() { + sub.unsub(errors.New("Unsub() called")) +} + +// unsub is the internal implementation of Unsub. +func (sub *Subscription) unsub(err error) { + // cancel the context (if it's not canceled already) + sub.cancel(err) + // mark subscription as closed and send a CLOSE to the relay (naïve sync.Once implementation) + if sub.live.CompareAndSwap(true, false) { + sub.Close() + } + // remove subscription from our map + sub.Client.Subscriptions.Delete(string(sub.id)) +} + +// Close just sends a CLOSE message. You probably want Unsub() instead. +func (sub *Subscription) Close() { + if sub.Client.IsConnected() { + closeMsg := closeenvelope.NewFrom(sub.id) + closeb := closeMsg.Marshal(nil) + <-sub.Client.Write(closeb) + } +} + +// Sub sets sub.Filters and then calls sub.Fire(ctx). +// The subscription will be closed if the context expires. +func (sub *Subscription) Sub(_ context.Context, ff *filter.S) { + sub.Filters = ff + chk.E(sub.Fire()) +} + +// Fire sends the "REQ" command to the relay. +func (sub *Subscription) Fire() (err error) { + var reqb []byte + reqb = reqenvelope.NewFrom(sub.id, sub.Filters).Marshal(nil) + sub.live.Store(true) + if err = <-sub.Client.Write(reqb); err != nil { + err = fmt.Errorf("failed to write: %w", err) + sub.cancel(err) + return + } + return +} diff --git a/pkg/protocol/ws/subscription_test.go b/pkg/protocol/ws/subscription_test.go new file mode 100644 index 0000000..e5a909d --- /dev/null +++ b/pkg/protocol/ws/subscription_test.go @@ -0,0 +1,104 @@ +package ws + +// const RELAY = "wss://nos.lol" + +// // test if we can fetch a couple of random events +// func TestSubscribeBasic(t *testing.T) { +// rl := mustRelayConnect(t, RELAY) +// defer rl.Close() +// +// sub, err := rl.Subscribe( +// context.Background(), filters.New( +// &filter.F{ +// Kinds: &kinds.T{K: []*kind.T{kind.TextNote}}, +// Limit: values.ToUintPointer(2), +// }, +// ), +// ) +// assert.NoError(t, err) +// timeout := time.After(5 * time.Second) +// n := 0 +// for { +// select { +// case event := <-sub.Events: +// assert.NotNil(t, event) +// n++ +// case <-sub.EndOfStoredEvents: +// assert.Equal(t, 2, n) +// sub.Unsub() +// return +// case <-rl.Context().Done(): +// t.Fatalf("connection closed: %v", rl.Context().Err()) +// case <-timeout: +// t.Fatalf("timeout") +// } +// } +// } +// +// // test if we can do multiple nested subscriptions +// func TestNestedSubscriptions(t *testing.T) { +// rl := mustRelayConnect(t, RELAY) +// defer rl.Close() +// +// n := atomic.Uint32{} +// +// // fetch 2 replies to a note +// sub, err := rl.Subscribe( +// context.Background(), filters.New( +// &filter.F{ +// Kinds: kinds.New(kind.TextNote), +// Tags: tags.New( +// tag.New( +// "e", +// "0e34a74f8547e3b95d52a2543719b109fd0312aba144e2ef95cba043f42fe8c5", +// ), +// ), +// Limit: values.ToUintPointer(3), +// }, +// ), +// ) +// assert.NoError(t, err) +// +// for { +// select { +// case ev := <-sub.Events: +// // now fetch author of this +// sub, err := rl.Subscribe( +// context.Background(), filters.New( +// &filter.F{ +// Kinds: kinds.New(kind.ProfileMetadata), +// Authors: tag.New(ev.PubKeyString()), +// Limit: values.ToUintPointer(1), +// }, +// ), +// ) +// assert.NoError(t, err) +// +// for { +// select { +// case <-sub.Events: +// // do another subscription here in "sync" mode, just so +// // we're sure things aren't blocking +// rl.QuerySync( +// context.Background(), +// &filter.F{Limit: values.ToUintPointer(1)}, +// ) +// n.Add(1) +// if n.Load() == 3 { +// // if we get here, it means the test passed +// return +// } +// case <-sub.Context.Done(): +// case <-sub.EndOfStoredEvents: +// sub.Unsub() +// } +// } +// case <-sub.EndOfStoredEvents: +// sub.Unsub() +// return +// case <-sub.Context.Done(): +// t.Fatalf("connection closed: %v", rl.Context().Err()) +// return +// } +// } +// } diff --git a/pkg/utils/atomic/bytes_test.go b/pkg/utils/atomic/bytes_test.go index e4e5be1..e310e64 100644 --- a/pkg/utils/atomic/bytes_test.go +++ b/pkg/utils/atomic/bytes_test.go @@ -22,10 +22,10 @@ package atomic import ( "encoding/json" + "next.orly.dev/pkg/utils" "runtime" "sync" "testing" - "utils.orly" "github.com/stretchr/testify/require" ) diff --git a/pkg/utils/atomic/example_test.go b/pkg/utils/atomic/example_test.go index 4d6ad9e..ecad2bc 100644 --- a/pkg/utils/atomic/example_test.go +++ b/pkg/utils/atomic/example_test.go @@ -22,7 +22,7 @@ package atomic_test import ( "fmt" - "utils.orly/atomic" + "next.orly.dev/pkg/utils/atomic" ) func Example() { diff --git a/pkg/utils/bufpool/bufpool.go b/pkg/utils/bufpool/bufpool.go index bb19cfd..c29006f 100644 --- a/pkg/utils/bufpool/bufpool.go +++ b/pkg/utils/bufpool/bufpool.go @@ -3,7 +3,7 @@ package bufpool import ( "sync" - "utils.orly/units" + "next.orly.dev/pkg/utils/units" ) const ( diff --git a/pkg/utils/fastequal.go b/pkg/utils/fastequal.go index 6d1c51a..45d40fa 100644 --- a/pkg/utils/fastequal.go +++ b/pkg/utils/fastequal.go @@ -1,6 +1,6 @@ package utils -import "utils.orly/constraints" +import "next.orly.dev/pkg/utils/constraints" func FastEqual[A constraints.Bytes, B constraints.Bytes](a A, b B) (same bool) { if len(a) != len(b) { diff --git a/pkg/utils/go.mod b/pkg/utils/go.mod deleted file mode 100644 index e84a802..0000000 --- a/pkg/utils/go.mod +++ /dev/null @@ -1,40 +0,0 @@ -module utils.orly - -go 1.25.0 - -require ( - encoders.orly v0.0.0-00010101000000-000000000000 - github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 - github.com/stretchr/testify v1.11.1 - go.uber.org/atomic v1.11.0 - golang.org/x/lint v0.0.0-20241112194109-818c5a804067 - honnef.co/go/tools v0.6.1 - lol.mleku.dev v1.0.2 -) - -require ( - github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect - golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect - golang.org/x/mod v0.27.0 // indirect - golang.org/x/sync v0.16.0 // indirect - golang.org/x/sys v0.35.0 // indirect - golang.org/x/tools v0.36.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) - -replace ( - acl.orly => ../acl - crypto.orly => ../crypto - database.orly => ../database - encoders.orly => ../encoders - interfaces.orly => ../interfaces - next.orly.dev => ../../ - protocol.orly => ../protocol - utils.orly => ../utils -) diff --git a/pkg/utils/go.sum b/pkg/utils/go.sum deleted file mode 100644 index 661bcb1..0000000 --- a/pkg/utils/go.sum +++ /dev/null @@ -1,58 +0,0 @@ -github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= -github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= -github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b h1:DXr+pvt3nC887026GRP39Ej11UATqWDmWuS99x26cD0= -golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b/go.mod h1:4QTo5u+SEIbbKW1RacMZq1YEfOBqeXa19JeshGi+zc4= -golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ= -golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/lint v0.0.0-20241112194109-818c5a804067 h1:adDmSQyFTCiv19j015EGKJBoaa7ElV0Q1Wovb/4G7NA= -golang.org/x/lint v0.0.0-20241112194109-818c5a804067/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= -golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= -golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= -golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= -golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= -golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI= -honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4= -lol.mleku.dev v1.0.2 h1:bSV1hHnkmt1hq+9nSvRwN6wgcI7itbM3XRZ4dMB438c= -lol.mleku.dev v1.0.2/go.mod h1:DQ0WnmkntA9dPLCXgvtIgYt5G0HSqx3wSTLolHgWeLA= -lukechampine.com/frand v1.5.1 h1:fg0eRtdmGFIxhP5zQJzM1lFDbD6CUfu/f+7WgAZd5/w= -lukechampine.com/frand v1.5.1/go.mod h1:4VstaWc2plN4Mjr10chUD46RAVGWhpkZ5Nja8+Azp0Q= diff --git a/pkg/utils/interrupt/main.go b/pkg/utils/interrupt/main.go index 69ce322..275c3a0 100644 --- a/pkg/utils/interrupt/main.go +++ b/pkg/utils/interrupt/main.go @@ -10,8 +10,8 @@ import ( "runtime" "lol.mleku.dev/log" - "utils.orly/atomic" - "utils.orly/qu" + "next.orly.dev/pkg/utils/atomic" + "next.orly.dev/pkg/utils/qu" ) // HandlerWithSource is an interrupt handling closure and the source location diff --git a/pkg/utils/normalize/normalize.go b/pkg/utils/normalize/normalize.go index 8bace3e..f0ff7dc 100644 --- a/pkg/utils/normalize/normalize.go +++ b/pkg/utils/normalize/normalize.go @@ -8,10 +8,10 @@ import ( "fmt" "net/url" - "encoders.orly/ints" "lol.mleku.dev/chk" "lol.mleku.dev/log" - "utils.orly/constraints" + "next.orly.dev/pkg/encoders/ints" + "next.orly.dev/pkg/utils/constraints" ) var ( diff --git a/pkg/utils/pointers/pointers.go b/pkg/utils/pointers/pointers.go index d0439e1..6e4c089 100644 --- a/pkg/utils/pointers/pointers.go +++ b/pkg/utils/pointers/pointers.go @@ -3,7 +3,7 @@ package pointers import ( "time" - "encoders.orly/timestamp" + "next.orly.dev/pkg/encoders/timestamp" ) // PointerToValue is a generic interface (type constraint) to refer to any diff --git a/pprof.go b/pprof.go index e68e8ad..4a48857 100644 --- a/pprof.go +++ b/pprof.go @@ -2,7 +2,7 @@ package main import ( "github.com/pkg/profile" - "utils.orly/interrupt" + "next.orly.dev/pkg/utils/interrupt" ) func startProfiler(mode string) { diff --git a/scripts/ubuntu_install_libsecp256k1.sh b/scripts/ubuntu_install_libsecp256k1.sh index 288df4c..6e38837 100755 --- a/scripts/ubuntu_install_libsecp256k1.sh +++ b/scripts/ubuntu_install_libsecp256k1.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -sudo apt -y install build-essential autoconf libtool +apt -y install build-essential autoconf libtool git wget cd $SCRIPT_DIR rm -rf secp256k1 git clone https://github.com/bitcoin-core/secp256k1.git