switch+router+server: move NextPaymentID to router

This commit moves the responsibility of generating a unique payment ID
from the switch to the router. This will make it easier for the router
to keep track of which HTLCs were successfully forwarded onto the
network, as it can query the switch for existing HTLCs as long as the
paymentIDs are kept.

The router is expected to maintain a map from paymentHash->paymentID,
such that they can be replayed on restart. This also lets the router
check the status of a sent payment after a restart, by querying the
switch for the paymentID in question.
This commit is contained in:
Johan T. Halseth
2019-05-16 15:27:28 +02:00
parent f1cb54f943
commit c9e8ff6a34
8 changed files with 84 additions and 45 deletions

View File

@@ -1417,7 +1417,7 @@ func testSkipLinkLocalForward(t *testing.T, eligible bool,
// We'll attempt to send out a new HTLC that has Alice as the first
// outgoing link. This should fail as Alice isn't yet able to forward
// any active HTLC's.
_, err = s.SendHTLC(aliceChannelLink.ShortChanID(), addMsg, nil)
_, err = s.SendHTLC(aliceChannelLink.ShortChanID(), 0, addMsg, nil)
if err == nil {
t.Fatalf("local forward should fail due to inactive link")
}
@@ -1743,7 +1743,7 @@ func TestSwitchSendPayment(t *testing.T) {
errChan := make(chan error)
go func() {
_, err := s.SendHTLC(
aliceChannelLink.ShortChanID(), update,
aliceChannelLink.ShortChanID(), 0, update,
newMockDeobfuscator())
errChan <- err
}()
@@ -1752,7 +1752,7 @@ func TestSwitchSendPayment(t *testing.T) {
// Send the payment with the same payment hash and same
// amount and check that it will be propagated successfully
_, err := s.SendHTLC(
aliceChannelLink.ShortChanID(), update,
aliceChannelLink.ShortChanID(), 0, update,
newMockDeobfuscator(),
)
errChan <- err