From 2f8ecd482077d82f2d1a937c7f979eaaa87a27b2 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 3 Dec 2025 08:54:00 +0000 Subject: feat: implement LMDB database backend - Add nostr-lmdb dependency (v0.44) for persistent storage - Create SharedDatabase type alias for database abstraction - Update all database-related functions to use trait object - Support runtime selection via NGIT_DATABASE_BACKEND env var Database backends: - memory: In-memory (default, fastest, no persistence) - lmdb: LMDB backend (persistent, general purpose) All 34 tests pass with the new implementation. --- src/git/handlers.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/git/handlers.rs') diff --git a/src/git/handlers.rs b/src/git/handlers.rs index e84cabb..8e5f5e1 100644 --- a/src/git/handlers.rs +++ b/src/git/handlers.rs @@ -4,9 +4,7 @@ use http_body_util::Full; use hyper::{body::Bytes, Response, StatusCode}; -use nostr_relay_builder::prelude::MemoryDatabase; use std::path::PathBuf; -use std::sync::Arc; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tracing::{debug, error, info, warn}; @@ -18,6 +16,7 @@ use super::protocol::{GitService, PktLine}; use super::subprocess::GitSubprocess; use super::try_set_head_if_available; +use crate::nostr::builder::SharedDatabase; use crate::nostr::events::RepositoryState; /// Handle GET /info/refs?service=git-{upload,receive}-pack @@ -178,7 +177,7 @@ pub async fn handle_upload_pack( pub async fn handle_receive_pack( repo_path: PathBuf, request_body: Bytes, - database: Option>, + database: Option, identifier: &str, owner_pubkey: &str, ) -> Result>, GitError> { @@ -310,7 +309,7 @@ pub async fn handle_receive_pack( /// 5. Validates that pushed refs match the state /// 6. Validates refs/nostr/ has valid event id and if event exists, `c` tag matches ref async fn authorize_push( - database: &Arc, + database: &SharedDatabase, identifier: &str, owner_pubkey: &str, request_body: &Bytes, -- cgit v1.2.3