Commit Graph

24 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
c965e0f4a9
invoiceregistry: make the invoice ntfn chan buffered
In this commit, we update the main invoiceEvents channel within the
invoiceregistry to now have an initial buffer size of 100. We do this as
it's been reported by users that on start up they're unable to actually
create or settle invoices manually. Traces have shown that this is due
to contention while holding the invoice mutex. To attempt to solve this,
we add an additional buffer to the channel as most sends will now be
routinely non blocking.
2018-07-17 16:53:28 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Olaoluwa Osuntokun
1189e703da
invoiceregistry: enforce stricter check on duplicate ntfn avoidance 2018-07-10 19:37:24 -07:00
Olaoluwa Osuntokun
6891729b5c
invoiceregistry: ensure we re-bind the loop variable within deliverBacklogEvents 2018-07-06 16:44:59 -07:00
Olaoluwa Osuntokun
9c1ed7fc7d
invoiceregistry: update AddInvoice to return addIndex of new invoice 2018-07-06 12:22:03 -07:00
Olaoluwa Osuntokun
2dcc2d63a6
invoiceregistry: ensure we never send duplicate add/settle notifications
In this commit, we add additional logic to the primary notification
dispatch loop to ensure that we'll never send the same add/settle event
to the same client twice.

Consider the case where as we're sending a client its notification
backlog, a new invoice is settled (index=9). In this case, the database
will be reflected immediately, and the event will also be queued for
notifying later. We'll send out this latest event during the backlog
clear, but then will send it again once we return back to the main loop.

To ensure that this never happens, we'll now record the last index that
we’ve sent to a client to ensure that we no longer are able to send
duplicate notification events.
2018-07-06 12:22:01 -07:00
Olaoluwa Osuntokun
3bedffcc1a
invoiceregistry: serialize all invoice modifications, eliminate extra db call for settle
In this commit, we now ensure that all modifications to the invoice DB
are properly serialized. This ensures that our time series within the
database will be properly coherent. Additionally, within SettleInvoice,
we remove an extra DB call by taking advantage of the new SettleInvoice
method which will return the invoice being settled as well.
2018-07-06 12:22:01 -07:00
Olaoluwa Osuntokun
7917fd2ab0
invoiceregistry: re-work logic to support delivering notification backlog
In this commit, we re-work the existing invoiceRegistry struct to
support delivering backlog notifications to subscription clients if
needed. Rather than using 1 goroutine per-client per-event, each client
now gains a concurrent notification queue. This queue will then be used
to ensure in-order delivery of all notifications from the
invoiceEventNotifier.

The SubscribeNotifications method now takes two params: addIndex, and
settleIndex. These should be the values of the last add index and settle
index the caller knows of. If specified (not zero), then we'll look up
all the notifications that the caller has missed, and then deliver those
before sending out any new notifications. In order to do this without
losing ordering of events, we've added a new central goroutine which
will ensure that all events are properly serialized.
2018-07-06 12:21:59 -07:00
hackerrdave
d98507abcf update comment for AddInvoice 2018-07-02 23:20:17 -04:00
Olaoluwa Osuntokun
c19c872cff
lnd: update invoiceRegistry to match new switch requirements 2018-06-29 16:03:51 -07:00
Olaoluwa Osuntokun
b6f64932c2
htlcswitch: face race condition in unit tests by returning invoice
In this commit we modify the primary InvoiceRegistry interface within
the package to instead return a direct value for LookupInvoice rather
than a pointer. This fixes an existing race condition wherein a caller
could modify or read the value of the returned invoice.
2017-11-11 16:09:29 -08:00
Olaoluwa Osuntokun
01b0ddf1c5
lnd+rpc: update RPC responses to convert mSAT to SAT 2017-08-22 00:52:56 -07:00
Olaoluwa Osuntokun
f217093c00
multi: replace usage of fastsha256 with crypto/sha256
This commit removes all instances of the fastsha256 library and
replaces it with the sha256 library in the standard library. This
change should see a number of performance improvements as the standard
library has highly optimized assembly instructions with use vectorized
instructions as the platform supports.
2017-03-15 18:56:41 -07:00
Andrey Samokhvalov
8fb54782e2 lnd: fix gosimple warnings 2017-03-13 16:30:23 -07:00
Trevin Hofmann
40c7bac3aa multi: fix a variety of typos throughout the repo 2017-01-17 17:02:56 -08:00
Olaoluwa Osuntokun
99c1ef6210
lnd: add additional logging statement on payment recv 2017-01-14 18:18:15 -08:00
Olaoluwa Osuntokun
5affed38fc
multi: update btcsuite API's to latest upstream changes
This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
2017-01-05 13:56:34 -08:00
Olaoluwa Osuntokun
6e2fb4e60d
lnd: minor typo fixes 2016-12-27 16:44:05 -08:00
Olaoluwa Osuntokun
862f29c6a2
invoices: properly set pointer in invoiceSubscription to fix panic 2016-11-21 21:33:34 -06:00
Olaoluwa Osuntokun
cfd9f8f6f0
invoices: add subscription to invoice updates
This commit adds the ability for clients within the daemon to register
for notifications that are dispatched once invoices are settled, or new
invoices are added. Such notifications can prove useful when
synchronizing higher level primitives, or implementing workflow within
desktop/mobile UI’s.
2016-10-14 19:49:04 -07:00
Olaoluwa Osuntokun
e29d8e7e06
lnd: add support for multi-hop (Sphinx) onion routed payments
This commit adds full support for multi-hop onion routed payments
within the daemon.

The switch has been greatly extended in order to gain the functionality
required to manage Sphinx payment circuits amongst active links. A
payment circuit is initiated when a link sends an HTLC add to the
downstream htlcSwitch it received from the upstream peer. The switch
then examines the parsed sphinx packet to set up the clear/settle ends
of the circuit. Created circuits can be re-used amongst HTLC payments
which share the same RHash.

All bandwidth updates within a link’s internal state are now managed
with atomic increments/decrements in order to avoid race conditions
amongst the two goroutines the switch currently uses.

Each channel’s htlcManager has also been extended to parse out the
next-hop contained within Sphinx packets, and construct a proper
htlcPkt such that the htlcSwitch can initiate then manage the payment
circuit.
2016-09-21 19:49:14 -07:00
Olaoluwa Osuntokun
62271768b0
peer: ensures invoices are marked as settled after redemption 2016-09-21 19:48:59 -07:00
Olaoluwa Osuntokun
0c4293ba82
lnd: extend the invoiceRegistry to wrap on-disk invoices with an in-memory cache
This commit extends the existing invoiceRegistry functionality to wrap
the on-disk invoices available via the channeldb with an in-memory
cache on invoices. Currently the in-memory cache is only reserved for
the storage of special “debug” invoices which all nodes are able to
settle immediately.
2016-09-21 19:48:22 -07:00
Olaoluwa Osuntokun
e1d5878df4
lnd: introduce the InvoiceRegistry
This commit introduces the invoice registry which is a central
repository of all outstanding invoices related to the daemon.

This registry will be used by the goroutines which manage the htlc’s
for a particular channel, and later by the point-to-point workflow
which negotiates the conditions for payment along with signed recipes.
2016-07-12 17:14:16 -07:00