@@ -104,9 +104,6 @@ where
104
104
105
105
pending_async_payments_messages : Mutex < Vec < ( AsyncPaymentsMessage , MessageSendInstructions ) > > ,
106
106
async_receive_offer_cache : Mutex < AsyncReceiveOfferCache > ,
107
- /// Blinded paths used to request offer paths from the static invoice server, if we are an async
108
- /// recipient.
109
- paths_to_static_invoice_server : Mutex < Vec < BlindedMessagePath > > ,
110
107
111
108
#[ cfg( feature = "dnssec" ) ]
112
109
pub ( crate ) hrn_resolver : OMNameResolver ,
@@ -146,7 +143,6 @@ where
146
143
pending_dns_onion_messages : Mutex :: new ( Vec :: new ( ) ) ,
147
144
148
145
async_receive_offer_cache : Mutex :: new ( AsyncReceiveOfferCache :: new ( ) ) ,
149
- paths_to_static_invoice_server : Mutex :: new ( Vec :: new ( ) ) ,
150
146
}
151
147
}
152
148
@@ -158,8 +154,6 @@ where
158
154
pub fn with_async_payments_offers_cache (
159
155
mut self , async_receive_offer_cache : AsyncReceiveOfferCache ,
160
156
) -> Self {
161
- self . paths_to_static_invoice_server =
162
- Mutex :: new ( async_receive_offer_cache. paths_to_static_invoice_server ( ) ) ;
163
157
self . async_receive_offer_cache = Mutex :: new ( async_receive_offer_cache) ;
164
158
self
165
159
}
@@ -174,15 +168,9 @@ where
174
168
pub fn set_paths_to_static_invoice_server (
175
169
& self , paths_to_static_invoice_server : Vec < BlindedMessagePath > ,
176
170
) -> Result < ( ) , ( ) > {
177
- // Store the paths in the async receive cache so they are persisted with the cache, but also
178
- // store them in-memory in the `OffersMessageFlow` so the flow has access to them when building
179
- // onion messages to send to the static invoice server, without introducing undesirable lock
180
- // dependencies with the cache.
181
- * self . paths_to_static_invoice_server . lock ( ) . unwrap ( ) =
182
- paths_to_static_invoice_server. clone ( ) ;
183
-
184
171
let mut cache = self . async_receive_offer_cache . lock ( ) . unwrap ( ) ;
185
- cache. set_paths_to_static_invoice_server ( paths_to_static_invoice_server)
172
+ cache. set_paths_to_static_invoice_server ( paths_to_static_invoice_server. clone ( ) ) ?;
173
+ Ok ( ( ) )
186
174
}
187
175
188
176
/// Gets the node_id held by this [`OffersMessageFlow`]`
@@ -1264,19 +1252,17 @@ where
1264
1252
R :: Target : Router ,
1265
1253
{
1266
1254
// Terminate early if this node does not intend to receive async payments.
1267
- if self . paths_to_static_invoice_server . lock ( ) . unwrap ( ) . is_empty ( ) {
1255
+ let mut cache = self . async_receive_offer_cache . lock ( ) . unwrap ( ) ;
1256
+ if cache. paths_to_static_invoice_server ( ) . is_empty ( ) {
1268
1257
return Ok ( ( ) ) ;
1269
1258
}
1270
1259
1271
1260
let duration_since_epoch = self . duration_since_epoch ( ) ;
1272
1261
1273
1262
// Update the cache to remove expired offers, and check to see whether we need new offers to be
1274
1263
// interactively built with the static invoice server.
1275
- let needs_new_offers = self
1276
- . async_receive_offer_cache
1277
- . lock ( )
1278
- . unwrap ( )
1279
- . prune_expired_offers ( duration_since_epoch, timer_tick_occurred) ;
1264
+ let needs_new_offers =
1265
+ cache. prune_expired_offers ( duration_since_epoch, timer_tick_occurred) ;
1280
1266
1281
1267
// If we need new offers, send out offer paths request messages to the static invoice server.
1282
1268
if needs_new_offers {
@@ -1292,18 +1278,19 @@ where
1292
1278
} ;
1293
1279
1294
1280
// We can't fail past this point, so indicate to the cache that we've requested new offers.
1295
- self . async_receive_offer_cache . lock ( ) . unwrap ( ) . new_offers_requested ( ) ;
1281
+ cache . new_offers_requested ( ) ;
1296
1282
1297
1283
let mut pending_async_payments_messages =
1298
1284
self . pending_async_payments_messages . lock ( ) . unwrap ( ) ;
1299
1285
let message = AsyncPaymentsMessage :: OfferPathsRequest ( OfferPathsRequest { } ) ;
1300
1286
enqueue_onion_message_with_reply_paths (
1301
1287
message,
1302
- & self . paths_to_static_invoice_server . lock ( ) . unwrap ( ) [ .. ] ,
1288
+ cache . paths_to_static_invoice_server ( ) ,
1303
1289
reply_paths,
1304
1290
& mut pending_async_payments_messages,
1305
1291
) ;
1306
1292
}
1293
+ core:: mem:: drop ( cache) ;
1307
1294
1308
1295
if timer_tick_occurred {
1309
1296
self . check_refresh_static_invoices (
0 commit comments