Commit a3c5cce
committed
Remove sync_wallets from hot paths
sync_wallets() issues serial HTTP requests to Esplora (fee rate
estimation, lightning tx sync across multiple block heights, BDK
wallet sync). This blocks the NAPI thread for a few seconds
via runtime.block_on(), which prevents the JS event loop from
polling nextEvent() for incoming HTLCs.
The 10+ second payment latency observed traces directly
to this: the sender's HTLC sits unprocessed while the receiver
node grinds through chain sync before the webhook handler can
start its event loop.
Removed sync_wallets from start_receiving, receive_payment,
get_invoice, and execute_payment. Receiving HTLCs only needs a
peer connection and channel manager, both provided by
node.start(). Sending payments routes via the gossip graph with
fee rates already cached by node.start().
Also disabled background wallet syncing (the 30s/80s interval
loop). For a webhook-based node that lives 40-60s, the immediate
first tick just competes with the peer handler for Esplora
bandwidth.
LDK uses highest_seen_timestamp (set via best_block_updated) for
inbound payment verification with a 2-hour grace window. A stale
chain tip could cause valid payments to be rejected as expired.
The platform's 30-minute ping cron calls sync_wallets via the
balance handler, which keeps the timestamp well within that
window. get_balance() also syncs explicitly before reading UTXOs.1 parent 63f07dd commit a3c5cce
1 file changed
Lines changed: 6 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
377 | 380 | | |
378 | 381 | | |
379 | 382 | | |
| |||
441 | 444 | | |
442 | 445 | | |
443 | 446 | | |
444 | | - | |
| 447 | + | |
445 | 448 | | |
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
449 | 452 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | 453 | | |
457 | 454 | | |
458 | 455 | | |
| |||
717 | 714 | | |
718 | 715 | | |
719 | 716 | | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | 717 | | |
726 | 718 | | |
727 | 719 | | |
| |||
848 | 840 | | |
849 | 841 | | |
850 | 842 | | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | 843 | | |
856 | 844 | | |
857 | 845 | | |
| |||
1154 | 1142 | | |
1155 | 1143 | | |
1156 | 1144 | | |
1157 | | - | |
1158 | | - | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | 1145 | | |
1167 | 1146 | | |
1168 | 1147 | | |
| |||
0 commit comments