Skip to content

Commit f93f4e0

Browse files
committed
chore: more logging in the RPC contract cache task
1 parent e363342 commit f93f4e0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

bin/alpen-bridge/src/rpc_server.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ impl BridgeRpc {
156156
) -> Self {
157157
// Initialize with empty cache
158158
let cached_contracts = Arc::new(RwLock::new(Vec::new()));
159+
160+
let start_time = Utc::now();
161+
159162
let instance = Self {
160-
start_time: Utc::now(),
163+
start_time,
161164
db,
162165
cached_contracts,
163166
p2p_handle,
@@ -191,6 +194,10 @@ impl BridgeRpc {
191194
// Spawn a background task to refresh the cache
192195
tokio::spawn(async move {
193196
let mut interval = interval(period);
197+
info!(
198+
?period,
199+
"initializing the background task for refreshing the RPC server cache"
200+
);
194201

195202
// Initial cache fill
196203
if let Ok(contracts) = query_as!(
@@ -200,6 +207,7 @@ impl BridgeRpc {
200207
.fetch_all(db.pool())
201208
.await
202209
{
210+
info!(num_contracts=%contracts.len(), "initializing the RPC server initial contract cache fill");
203211
let mut cache_lock = cached_contracts.write().await;
204212
// Convert raw records to typed records
205213
*cache_lock = contracts
@@ -219,7 +227,7 @@ impl BridgeRpc {
219227
(record, config)
220228
})
221229
.collect();
222-
info!(cache_len=%cache_lock.len(), "Contracts cache initialized");
230+
info!(cache_len=%cache_lock.len(), "RPC server Contracts cache initialized");
223231

224232
// drop the lock!
225233
drop(cache_lock);
@@ -239,6 +247,7 @@ impl BridgeRpc {
239247
.await
240248
{
241249
Ok(contracts) => {
250+
info!(num_contracts=%contracts.len(), "initializing the RPC server periodic contract cache refresh");
242251
let mut cache_lock = cached_contracts.write().await;
243252
// Convert raw records to typed records
244253
*cache_lock = contracts
@@ -258,7 +267,7 @@ impl BridgeRpc {
258267
(record, config)
259268
})
260269
.collect();
261-
debug!(cache_len=%cache_lock.len(), "Contracts cache refreshed");
270+
debug!(num_contracts=%cache_lock.len(), "Contracts cache refreshed");
262271

263272
// drop the lock!
264273
drop(cache_lock);

0 commit comments

Comments
 (0)