Skip to content

Commit 221a398

Browse files
committed
fixes potential cache issues
1 parent 0868273 commit 221a398

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

applications/minotari_node/src/http/handler/sync_utxos_by_block.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2025 The Tari Project
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
use std::{fmt::Display, sync::Arc};
4+
use std::{cmp, fmt::Display, sync::Arc};
55

66
use axum::{
77
extract::Query,
@@ -87,6 +87,7 @@ pub async fn handle<B: BlockchainBackend + 'static>(
8787
let tip_info = query_service.get_tip_info().await.map_err(error_handler_with_message)?;
8888
let tip_height = tip_info.metadata.map(|m| m.best_block_height()).unwrap_or(0);
8989
let height;
90+
let exclude_spent = request.exclude_spent;
9091
let mut response = match request.version {
9192
0 => {
9293
let response = query_service
@@ -107,7 +108,14 @@ pub async fn handle<B: BlockchainBackend + 'static>(
107108
body.into_response()
108109
},
109110
};
110-
let last_height = height.unwrap_or(0);
111+
let last_height = if let true = exclude_spent {
112+
// if we're excluding spent outputs we cannot cache for longer than a day, so we force the "height" so that the
113+
// caching will only be a max of 1 day. Wallets will sent full without excluding spends the last 1000 blocks so
114+
// this leaves a margin for wallets to get data if it changed.
115+
cmp::min(height.unwrap_or(0), tip_height.saturating_add(2500))
116+
} else {
117+
height.unwrap_or(0)
118+
};
111119

112120
apply_cache_control(
113121
response.headers_mut(),

0 commit comments

Comments
 (0)