invoicerpc: move hop hint to constant and add tests to select hop hint

This commit is contained in:
carla
2022-01-27 15:09:21 +02:00
parent 80bf4bf014
commit 714a1fb05c
2 changed files with 554 additions and 1 deletions

View File

@@ -31,6 +31,11 @@ const (
// DefaultAMPInvoiceExpiry is the default invoice expiry for new AMP
// invoices.
DefaultAMPInvoiceExpiry = 30 * 24 * time.Hour
// hopHintFactor is factor by which we scale the total amount of
// inbound capacity we want our hop hints to represent, allowing us to
// have some leeway if peers go offline.
hopHintFactor = 2
)
// AddInvoiceConfig contains dependencies for invoice creation.
@@ -670,7 +675,6 @@ func SelectHopHints(amtMSat lnwire.MilliSatoshi, cfg *SelectHopHintsCfg,
// or if the sum of available bandwidth in the routing hints exceeds 2x
// the payment amount. We do 2x here to account for a margin of error
// if some of the selected channels no longer become operable.
hopHintFactor := lnwire.MilliSatoshi(2)
for i := 0; i < len(openChannels); i++ {
// If we hit either of our early termination conditions, then
// we'll break the loop here.