let rec loop () : unit = let _ = P2p.on_new_connection p2p (fun _ conn -> let rec conn_loop () = (fun () -> Format.eprintf "hello\n@."; P2p.send p2p conn (Pong peer_id) >>= function | _ -> ( P2p.recv p2p conn >>= function | Ok msg -> ( match msg with | Ping -> Format.eprintf "Received a Ping!\n@."; Lwt.return_unit | Pong id -> Format.eprintf "Received a Pong!@."; Node_Event.(emit received_pong) id) | Error _ -> Lwt.return_unit)) |> Lwt.async; conn_loop () in conn_loop ()) in loop () in loop (); Lwt.pause ()