1#![warn(missing_docs)]
2//! This crate provides `gatewayd`, the Fedimint gateway binary.
3//!
4//! The binary contains logic for sending/receiving Lightning payments on behalf
5//! of Fedimint clients in one or more connected Federations.
6//!
7//! It runs a webserver with a REST API that can be used by Fedimint
8//! clients to request routing of payments through the Lightning Network.
9//! The API also has endpoints for managing the gateway.
1011use std::sync::Arc;
1213use fedimint_core::fedimint_build_code_version_env;
14use fedimint_core::util::handle_version_hash_command;
15use fedimint_gateway_server::Gateway;
16use fedimint_logging::{LOG_GATEWAY, TracingSetup};
17#[cfg(not(target_env = "msvc"))]
18use tikv_jemallocator::Jemalloc;
19use tracing::info;
2021#[cfg(not(target_env = "msvc"))]
22#[global_allocator]
23// rocksdb suffers from memory fragmentation when using standard allocator
24static GLOBAL: Jemalloc = Jemalloc;
2526fn main() -> Result<(), anyhow::Error> {
27let runtime = Arc::new(tokio::runtime::Runtime::new()?);
28 runtime.block_on(async {
29 handle_version_hash_command(fedimint_build_code_version_env!());
30 TracingSetup::default().init()?;
31let gatewayd = Gateway::new_with_default_modules().await?;
32let shutdown_receiver = gatewayd.clone().run(runtime.clone()).await?;
33 shutdown_receiver.await;
34 gatewayd.unannounce_from_all_federations().await;
35info!(target: LOG_GATEWAY, "Gatewayd exiting...");
36Ok(())
37 })
38}