Skip to content

Feature:gemini enable p2p git-clone function #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 0 commits into from

Conversation

wujian0327
Copy link
Contributor

@wujian0327 wujian0327 commented Mar 19, 2025

Now you can start a p2p network through gemini module:
For relay:

 cargo run --bin aries

For client, you should specify bootstrap_node

cargo run --bin mega service http --bootstrap-node 127.0.0.1:8001

In the p2p module of gemini, you can use some methods :

  • gemini::p2p::client::run(context, bootstrap_node) to join a network
  • gemini::p2p::client::request_git_clone(context, bootstrap_node, path, to_peer_id) to clone a repo from to_peer_id
  • gemini::p2p::client::request_lfs(context, bootstrap_node, oid, to_peer_id) to download a lfs from to_peer_id

For example to clone a repo with lfs:

  1. join the network:
cargo run --bin mega service http --bootstrap-node 47.74.41.94:8001
  1. p2p clone repo:
curl localhost:8000/api/v1/mega/p2p/repo_fork?identifier=p2p://23G4CgqpxezqrFNXbWyF9ESzh68acrcJk2y3xYJRW6VgA/third-part/lfs_test.git
  1. clone the repo to local disk
 git clone http://localhost:8000/third-part/lfs_test.git

Link:#841

Copy link

vercel bot commented Mar 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 6:57am

@genedna genedna requested a review from Copilot March 19, 2025 05:43
@genedna genedna added this to the 0.3.0 - Decentralized Git milestone Mar 19, 2025
@genedna genedna added this to r2cn and Mega Mar 19, 2025
@genedna genedna moved this to In progress in Mega Mar 19, 2025
@genedna genedna moved this to In progress in r2cn Mar 19, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a P2P git-clone functionality in the gemini module and its integration in the gateway HTTP server. Key changes include:

  • Updates to repository identifier utility functions and the addition of a new LFS pointer parser.
  • Implementation of new P2P endpoints (repo_fork, repo_share, and peer_id) in the gateway API.
  • Enhancements to the P2P relay code for handling multiple connection types and data transfers (including git clone and LFS).

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
gemini/src/util.rs Refactored identifier functions and added LFS pointer data parsing.
gemini/src/http/handler.rs Introduced get_path_from_identifier and a corresponding test case.
gateway/src/api/p2p_router.rs Added new P2P API endpoints for fork, share, and peer_id retrieval functions.
gemini/Cargo.toml Added dependencies for futures util, tokio util, tokio stream, and tracing subscriber.
gemini/src/p2p/relay.rs Updated relay connection handling with refined connection map usage and added git clone/LFS support.
gemini/src/p2p/mod.rs Extended the P2P action enum and introduced new RequestData/ResponseData structures and headers.
gateway/src/https_server.rs Integrated the new p2p_router and updated bootstrap logic for P2P network joining.
gateway/src/api/nostr_router.rs Adjusted repo_path_to_identifier usage consistent with the latest signature changes.
jupiter/callisto/src/import_refs.rs & db_enums.rs Added serde derives for improved serialization support in data models.
Comments suppressed due to low confidence (3)

gateway/src/api/p2p_router.rs:31

  • [nitpick] Consider updating the error message to 'Identifier not provided' for better grammatical clarity.
String::from("Identifier not provide\n")

gateway/src/api/p2p_router.rs:58

  • [nitpick] Consider updating the error message to 'bootstrap node not provided' to improve clarity and maintain consistency.
String::from("bootstrap node not provide\n")

gateway/src/api/p2p_router.rs:84

  • [nitpick] Consider updating the error message to 'path not provided' for consistency and clarity.
return Err((StatusCode::BAD_REQUEST, String::from("path not provide\n")));

@wujian0327 wujian0327 marked this pull request as ready for review March 19, 2025 06:42
@genedna genedna moved this from In progress to In review in Mega Mar 19, 2025
@genedna genedna moved this from In progress to In review in r2cn Mar 19, 2025
@wujian0327 wujian0327 closed this Mar 19, 2025
@github-project-automation github-project-automation bot moved this from In review to Done in r2cn Mar 19, 2025
@github-project-automation github-project-automation bot moved this from In review to Done in Mega Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants