@@ -156,8 +156,11 @@ impl BridgeRpc {
156
156
) -> Self {
157
157
// Initialize with empty cache
158
158
let cached_contracts = Arc :: new ( RwLock :: new ( Vec :: new ( ) ) ) ;
159
+
160
+ let start_time = Utc :: now ( ) ;
161
+
159
162
let instance = Self {
160
- start_time : Utc :: now ( ) ,
163
+ start_time,
161
164
db,
162
165
cached_contracts,
163
166
p2p_handle,
@@ -191,6 +194,10 @@ impl BridgeRpc {
191
194
// Spawn a background task to refresh the cache
192
195
tokio:: spawn ( async move {
193
196
let mut interval = interval ( period) ;
197
+ info ! (
198
+ ?period,
199
+ "initializing the background task for refreshing the RPC server cache"
200
+ ) ;
194
201
195
202
// Initial cache fill
196
203
if let Ok ( contracts) = query_as ! (
@@ -200,6 +207,7 @@ impl BridgeRpc {
200
207
. fetch_all ( db. pool ( ) )
201
208
. await
202
209
{
210
+ info ! ( num_contracts=%contracts. len( ) , "initializing the RPC server initial contract cache fill" ) ;
203
211
let mut cache_lock = cached_contracts. write ( ) . await ;
204
212
// Convert raw records to typed records
205
213
* cache_lock = contracts
@@ -219,7 +227,7 @@ impl BridgeRpc {
219
227
( record, config)
220
228
} )
221
229
. collect ( ) ;
222
- info ! ( cache_len=%cache_lock. len( ) , "Contracts cache initialized" ) ;
230
+ info ! ( cache_len=%cache_lock. len( ) , "RPC server Contracts cache initialized" ) ;
223
231
224
232
// drop the lock!
225
233
drop ( cache_lock) ;
@@ -239,6 +247,7 @@ impl BridgeRpc {
239
247
. await
240
248
{
241
249
Ok ( contracts) => {
250
+ info ! ( num_contracts=%contracts. len( ) , "initializing the RPC server periodic contract cache refresh" ) ;
242
251
let mut cache_lock = cached_contracts. write ( ) . await ;
243
252
// Convert raw records to typed records
244
253
* cache_lock = contracts
@@ -258,7 +267,7 @@ impl BridgeRpc {
258
267
( record, config)
259
268
} )
260
269
. collect ( ) ;
261
- debug ! ( cache_len =%cache_lock. len( ) , "Contracts cache refreshed" ) ;
270
+ debug ! ( num_contracts =%cache_lock. len( ) , "Contracts cache refreshed" ) ;
262
271
263
272
// drop the lock!
264
273
drop ( cache_lock) ;
0 commit comments