File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ pub async fn select_coins_to_spend(
251
251
total : u128 ,
252
252
max : u16 ,
253
253
asset_id : & AssetId ,
254
+ allow_partial : bool ,
254
255
exclude : & Exclude ,
255
256
batch_size : usize ,
256
257
) -> Result < Vec < CoinsToSpendIndexKey > , CoinsQueryError > {
@@ -287,11 +288,13 @@ pub async fn select_coins_to_spend(
287
288
big_coins ( big_coins_stream, adjusted_total, max, exclude) . await ?;
288
289
289
290
if selected_big_coins_total < total {
290
- return Err ( CoinsQueryError :: InsufficientCoinsForTheMax {
291
- asset_id : * asset_id,
292
- collected_amount : selected_big_coins_total,
293
- max,
294
- } ) ;
291
+ if !allow_partial {
292
+ return Err ( CoinsQueryError :: InsufficientCoinsForTheMax {
293
+ asset_id : * asset_id,
294
+ collected_amount : selected_big_coins_total,
295
+ max,
296
+ } )
297
+ }
295
298
}
296
299
297
300
let Some ( last_selected_big_coin) = selected_big_coins. last ( ) else {
@@ -1322,6 +1325,7 @@ mod tests {
1322
1325
TOTAL ,
1323
1326
MAX ,
1324
1327
& AssetId :: default ( ) ,
1328
+ false ,
1325
1329
& exclude,
1326
1330
BATCH_SIZE ,
1327
1331
)
@@ -1384,6 +1388,7 @@ mod tests {
1384
1388
TOTAL ,
1385
1389
MAX ,
1386
1390
& AssetId :: default ( ) ,
1391
+ false ,
1387
1392
& exclude,
1388
1393
BATCH_SIZE ,
1389
1394
)
@@ -1431,6 +1436,7 @@ mod tests {
1431
1436
TOTAL ,
1432
1437
MAX ,
1433
1438
& AssetId :: default ( ) ,
1439
+ false ,
1434
1440
& exclude,
1435
1441
BATCH_SIZE ,
1436
1442
)
@@ -1459,6 +1465,7 @@ mod tests {
1459
1465
TOTAL ,
1460
1466
MAX ,
1461
1467
& AssetId :: default ( ) ,
1468
+ false ,
1462
1469
& exclude,
1463
1470
BATCH_SIZE ,
1464
1471
)
@@ -1486,6 +1493,7 @@ mod tests {
1486
1493
TOTAL ,
1487
1494
MAX ,
1488
1495
& AssetId :: default ( ) ,
1496
+ false ,
1489
1497
& exclude,
1490
1498
BATCH_SIZE ,
1491
1499
)
@@ -1521,6 +1529,7 @@ mod tests {
1521
1529
TOTAL ,
1522
1530
MAX ,
1523
1531
& asset_id,
1532
+ false ,
1524
1533
& exclude,
1525
1534
BATCH_SIZE ,
1526
1535
)
Original file line number Diff line number Diff line change @@ -435,6 +435,7 @@ async fn coins_to_spend_with_cache(
435
435
total_amount,
436
436
max,
437
437
& asset_id,
438
+ asset. allow_partial . unwrap_or ( false ) ,
438
439
excluded,
439
440
db. batch_size ,
440
441
)
You can’t perform that action at this time.
0 commit comments