global: snapshot

This commit is contained in:
nym21
2026-02-12 22:52:57 +01:00
parent 3bc20a0a46
commit b779edc0d6
60 changed files with 8720 additions and 1504 deletions
+22
View File
@@ -62,6 +62,28 @@ impl MempoolRoutes for ApiRouter<AppState> {
},
),
)
.api_route(
"/api/mempool/price",
get_with(
async |headers: HeaderMap, State(state): State<AppState>| {
state
.cached_json(&headers, CacheStrategy::MaxAge(5), |q| q.live_price())
.await
},
|op| {
op.id("get_live_price")
.mempool_tag()
.summary("Live BTC/USD price")
.description(
"Returns the current BTC/USD price in cents, derived from \
on-chain round-dollar output patterns in the last 12 blocks \
plus mempool.",
)
.ok_response::<u64>()
.server_error()
},
),
)
.api_route(
"/api/v1/fees/mempool-blocks",
get_with(
+12 -1
View File
@@ -71,7 +71,18 @@ impl Server {
mut request: Request<Body>,
next: Next|
-> Response<Body> {
request.extensions_mut().insert(connect_info.0);
let mut addr = connect_info.0;
// When behind a reverse proxy (e.g. cloudflared), the direct
// connection comes from loopback but the request is external.
// Mark it as non-loopback so it gets the stricter limit.
if addr.ip().is_loopback()
&& request.headers().contains_key("CF-Connecting-IP")
{
addr.set_ip(std::net::Ipv4Addr::UNSPECIFIED.into());
}
request.extensions_mut().insert(addr);
next.run(request).await
},
);