@@ -55,8 +55,40 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5555 i += 1 ;
5656 }
5757
58+ // Parse P2P flags (feature-gated at compile time).
59+ #[ cfg( feature = "p2p" ) ]
60+ let p2p_config = {
61+ let p2p = aingle_cortex:: p2p:: config:: P2pConfig :: from_args ( & args) ;
62+ if let Err ( e) = p2p. validate ( ) {
63+ eprintln ! ( "Invalid P2P config: {}" , e) ;
64+ std:: process:: exit ( 1 ) ;
65+ }
66+ p2p
67+ } ;
68+
5869 // Create and run server
59- let server = CortexServer :: new ( config) ?;
70+ #[ allow( unused_mut) ]
71+ let mut server = CortexServer :: new ( config) ?;
72+
73+ // Start P2P manager if enabled.
74+ #[ cfg( feature = "p2p" ) ]
75+ if p2p_config. enabled {
76+ match aingle_cortex:: p2p:: manager:: P2pManager :: start (
77+ p2p_config. clone ( ) ,
78+ server. state ( ) . clone ( ) ,
79+ )
80+ . await
81+ {
82+ Ok ( manager) => {
83+ // SAFETY: we have exclusive access before serving.
84+ server. state_mut ( ) . p2p = Some ( manager) ;
85+ tracing:: info!( "P2P manager started on port {}" , p2p_config. port) ;
86+ }
87+ Err ( e) => {
88+ tracing:: error!( "P2P manager failed to start: {}" , e) ;
89+ }
90+ }
91+ }
6092
6193 // Set up graceful shutdown
6294 let shutdown_signal = async {
@@ -84,9 +116,17 @@ fn print_help() {
84116 println ! ( " -V, --version Print version and exit" ) ;
85117 println ! ( " --help Print this help message" ) ;
86118 println ! ( ) ;
119+ println ! ( "P2P OPTIONS (requires --features p2p):" ) ;
120+ println ! ( " --p2p Enable P2P triple synchronization" ) ;
121+ println ! ( " --p2p-port <PORT> QUIC listen port (default: 19091)" ) ;
122+ println ! ( " --p2p-seed <SEED> Network isolation seed" ) ;
123+ println ! ( " --p2p-peer <ADDR> Manual peer address (repeatable)" ) ;
124+ println ! ( " --p2p-mdns Enable mDNS discovery" ) ;
125+ println ! ( ) ;
87126 println ! ( "ENDPOINTS:" ) ;
88127 println ! ( " REST API: http://<host>:<port>/api/v1/" ) ;
89128 println ! ( " GraphQL: http://<host>:<port>/graphql" ) ;
90129 println ! ( " SPARQL: http://<host>:<port>/sparql" ) ;
91130 println ! ( " Health: http://<host>:<port>/api/v1/health" ) ;
131+ println ! ( " P2P Status: http://<host>:<port>/api/v1/p2p/status" ) ;
92132}
0 commit comments