Commit Graph

350 Commits

Author SHA1 Message Date
Conner Fromknecht
2e5bc783f7
peer: preallocate errchans opt 2019-03-05 17:08:35 -08:00
Conner Fromknecht
f39edd8000
peer: add SendMessageLazy 2019-03-05 17:08:22 -08:00
Conner Fromknecht
660bbaf646
peer: add message reordering based on priority 2019-03-05 17:08:05 -08:00
Conner Fromknecht
6f1ccf14e9
Revert "peer: reduce write timeout to 10s"
This reverts commit db2c104111c3c12e1651120fe5a51ce03dad8c58.
2019-03-04 13:55:09 -08:00
Olaoluwa Osuntokun
a6cf6f4237
lnwallet+peer: remove unnecessary MaxPendingAmount method
We don't need this method, as we can directly access it from the peer
via public fields with its current usage.
2019-02-25 12:51:31 -03:00
Olaoluwa Osuntokun
b13d8cd261
Merge pull request #2434 from valentinewallace/fwding-policy-max-htlc
Set max HTLC in forwarding policies.
2019-02-25 12:43:15 -03:00
Conner Fromknecht
db2c104111
peer: reduce write timeout to 10s 2019-02-21 20:11:47 -08:00
Conner Fromknecht
603601a4c8
peer+server: use peer-level readPool 2019-02-21 20:11:33 -08:00
Conner Fromknecht
9a3c0b8bca
peer+server: switch to pool.Write from pool.WriteBuffer 2019-02-21 20:10:51 -08:00
Valentine Wallace
90cbf9fe35 peer: set max htlc when loading active channels on start 2019-02-21 18:39:32 -08:00
Valentine Wallace
20b3114100 htlcswitch+lnwallet+peer: default max htlc in fwding policy of new chans
In this commit, we set a default max HTLC in the forwarding
policies of newly open channels.

The ForwardingPolicy's MaxHTLC field (added in this commit)
will later be used to decide whether an HTLC satisfies our policy before
forwarding it.

To ensure the ForwardingPolicy's MaxHTLC default matches the max HTLC
advertised in the ChannelUpdate sent out for this channel,  we also add
a MaxPendingAmount() function to the lnwallet.Channel.
2019-02-21 18:39:32 -08:00
Olaoluwa Osuntokun
9d23d382fc
Merge pull request #2419 from cfromknecht/brontide-buffer-pool
brontide: read buffer pool
2019-02-18 17:51:17 -08:00
Conner Fromknecht
6f96d04b72
multi: add buffer.Write and pool.WriteBuffer, make GCQueue generic 2019-02-15 19:31:24 -08:00
Conner Fromknecht
de282172a1
peer+server+test_utlils: use new ChanStatusManager
This commit hooks up the new netann.ChanStatusManager,
replacing the prior method which used the
watchChannelStatus goroutine.
2019-02-14 17:13:44 -08:00
Olaoluwa Osuntokun
bceb048a76
Merge pull request #2385 from cfromknecht/peer-write-buffer
peer: write buffer pool
2019-02-01 17:04:30 -08:00
Olaoluwa Osuntokun
5167b02312
Merge pull request #2500 from Roasbeef/mandatory-dlp
server: require the DLP bit for all incoming/outgoing connections
2019-01-31 20:14:15 -08:00
Conner Fromknecht
24dcd3c44e
peer+server: use server-wide writeBufferPool for peer write buffers 2019-01-31 19:21:36 -08:00
Olaoluwa Osuntokun
f57f40e767
channeldb: add prefix naming to ChannelStatus enum variables
In this commit, we add a prefix naming scheme to the ChannelStatus enum
variables. We do this as it enables outside callers to more easily
identify each individual enum variable as a part of the greater
enum-like type.
2019-01-28 20:24:32 -08:00
Valentine Wallace
0fd6004958
multi: partition lnwire.ChanUpdateFlag into ChannelFlags and MessageFlags
In this commit:

* we partition lnwire.ChanUpdateFlag into two (ChanUpdateChanFlags and
ChanUpdateMsgFlags), from a uint16 to a pair of uint8's

* we rename the ChannelUpdate.Flags to ChannelFlags and add an
additional MessageFlags field, which will be used to indicate the
presence of the optional field HtlcMaximumMsat within the ChannelUpdate.

* we partition ChannelEdgePolicy.Flags into message and channel flags.
This change corresponds to the partitioning of the ChannelUpdate's Flags
field into MessageFlags and ChannelFlags.

Co-authored-by: Johan T. Halseth <johanth@gmail.com>
2019-01-22 08:42:26 +01:00
Olaoluwa Osuntokun
b7244244ae
peer: disconnect peers that don't have our required feature bits 2019-01-18 18:30:55 -08:00
Conner Fromknecht
2cf220a137
peer: handle message encoding errors on write
In this commit, we modify the peer's writeMessage
method to properly handle errors returned from
encoding an lnwire message and from setting the
write deadline on the connection. Since an error
would likely result in an empty byte slice, the
worse case seems to be that we may have tried to
send an empty message on the wire.

Lastly, we correct the way we compute bytes sent
on the wire to properly count the number of bytes
*written*, and not just the length of the encoded
message.
2019-01-10 19:49:44 -08:00
Olaoluwa Osuntokun
a49e39de75
peer: don't d/c on invalid node alias 2019-01-07 12:53:45 -08:00
Joost Jager
6c027e2bc9 htlcswitch: remove lnrpc dependency
This commits removes an unwanted dependency that prevents
moving parts of rpcserver to a sub server.
2019-01-03 09:07:56 +01:00
Olaoluwa Osuntokun
fa160f559c
multi: replace per channel sigPool with global daemon level sigPool
In this commit, we remove the per channel `sigPool` within the
`lnwallet.LightningChannel` struct. With this change, we ensure that as
the number of channels grows, the number of gouroutines idling in the
sigPool stays constant. It's the case that currently on the daemon, most
channels are likely inactive, with only a hand full actually
consistently carrying out channel updates. As a result, this change
should reduce the amount of idle CPU usage, as we have less active
goroutines in select loops.

In order to make this change, the `SigPool` itself has been publicly
exported such that outside callers can make a `SigPool` and pass it into
newly created channels. Since the sig pool now lives outside the
channel, we were also able to do away with the Stop() method on the
channel all together.

Finally, the server is the sub-system that is currently responsible for
managing the `SigPool` within lnd.
2018-12-16 15:40:14 -08:00
Johan T. Halseth
0dd7eed64e
peer: define resendChanSyncMsg
This method is used to fetch channel sync messages for closed channels
from the db, and respond to the peer.
2018-11-21 10:28:56 +01:00
Johan T. Halseth
780e1bbead
peer: correct variable name, print error 2018-11-21 10:12:04 +01:00
chokoboko
ec1a77dccb Fix peer handshake timeout error message
Use proper format verb for handshakeTimeout
2018-11-12 12:45:31 +02:00
Conner Fromknecht
b0b2475660
peer: remove quit chan from AddMsg signature 2018-11-01 17:08:24 -07:00
Conner Fromknecht
10b35a8f20
main: remove disable log in testing + clean up imports 2018-10-05 13:04:45 +09:00
Olaoluwa Osuntokun
13802b4218
Merge pull request #1963 from wpaulino/create-chan-buckets-once
channeldb: ensure channel buckets are only created once
2018-09-28 17:06:39 -07:00
Johan T. Halseth
b712b861f8
peer: make AddNewChannel take OpenChannel
This commit makes the AddNewChannel expect a OpenChannel instead of a
LightningChannel struct. This moves the responsibility for starting the
LightningChannel from the fundingmanager to the peer, and we can defer
the channel restoration until we know that the channel is not already
active.
2018-09-28 08:59:27 +02:00
Johan T. Halseth
240318befe
peer: return error on newChanReq
Previously the errors weren't returned back to the sender of the new
channel, making it impossible to tell whether it suceeded or not.
2018-09-28 08:59:26 +02:00
Wilmer Paulino
828ecfe343
peer: skip sending active channel updates for pending open channels
In this commit, we skip sending active channel update for pending open
channels as they are not yet part of the graph.
2018-09-21 17:26:37 -07:00
Wilmer Paulino
99a4952239
server+peer: check ErrEdgeNotFound when enabling/disabling a channel
In this commit, we also check ErrEdgeNotFound when attempting to send an
active/inactive channel update for a channel to the network. We do this
as it's possible that a channel has confirmed, but it still does not
meet the required number of confirmations to be publicly announced.
2018-09-21 17:24:36 -07:00
Wilmer Paulino
ea51ec34b1
peer: prune persistent peer connection on zero on-disk channels
In this commit, we fix a small bug with regards to the persistent peer
connection pruning logic. Before this commit, it'd be the case that we'd
prune a persistent connection to a peer if all links happen to be
inactive. This isn't ideal, as the channels are still open, so we should
always be atttempting to connect to them. We fix this by looking at the
set of channels on-disk instead and prune the persistent connection if
there aren't any.
2018-09-05 18:30:45 -07:00
Conner Fromknecht
51090a41b5
peer: log disconnect to info, remove go-errors pkg 2018-09-04 17:28:51 -07:00
Conner Fromknecht
adf6b8619f
peer: dispatch gossip sync in peer start
This commit moves the gossip sync dispatch
such that it is more tightly coupled to the
life cycle of the peer. In testing, I noticed
that the gossip syncer needs to be dispatched
before the first gossip messages come across
the wire.

The prior spawn location in the server happens
after starting all of the peer's goroutines,
which could permit an ordering where the
gossip syncer has not yet been registered.
The new location registers the gossip syncer
within the read handler such that the call is
blocks before any messages are read.
2018-09-04 17:28:50 -07:00
Olaoluwa Osuntokun
6aebd053a3
Merge pull request #1823 from cfromknecht/dont-dc-on-link-fail
peer: ensure link failures are processed in peer life cycle
2018-09-03 19:56:19 -07:00
Olaoluwa Osuntokun
edf304ad8b
peer: ensure we unlock the msgCond during peer msgConsumer exit 2018-09-03 17:03:05 -07:00
Conner Fromknecht
48dc38d9f9
peer: ensure link failures are processed in peer life cycle 2018-08-30 17:36:13 -07:00
Olaoluwa Osuntokun
28a59362d6
peer: ensure readHandler doesn't block on AddMsg to msgStream
In this commit, we add a quit channel to the AddMsg method of the
msgStream struct. Before this commit, if the queue was full, the
readHandler would block and be unable to exit. We remedy this by
leveraging the existing quit channel of the peer as an additional select
case within the AddMsg method.
2018-08-26 20:02:50 -07:00
Olaoluwa Osuntokun
f2db18733b
peer: before and after obtaining link for chan update, check quit signal 2018-08-25 17:30:17 -07:00
Olaoluwa Osuntokun
7f480f723c
peer: add QuitSignal to ensure peer struct adheres to lnpeer.Peer interface 2018-08-25 17:30:14 -07:00
Olaoluwa Osuntokun
0e510c8b5c
funding+peer: don't attempt to deliver messages if the peer is shutting down 2018-08-25 17:30:11 -07:00
Olaoluwa Osuntokun
d6f534cfa5
peer: don't attempt to re-enable any private channels 2018-08-25 17:30:09 -07:00
Olaoluwa Osuntokun
5130949604
peer: allow msgConsumers to also exit on peer quit send 2018-08-25 17:30:07 -07:00
Olaoluwa Osuntokun
33c5c9661e
peer: allow msgStream goroutines to quit within the apply function
In this commit, we thread through the quit of the peer to the execution
of the apply function for a msgStream. This change ensures that if the
target is still processing the message, then the peer is able to exit
cleanly and not block insensately.
2018-08-25 17:30:05 -07:00
Olaoluwa Osuntokun
e4e4a6ab58
peer: move atomic var increment in msgConsumer goroutine to defer
In this commit we move the atomic var increment that signals the
consumer goourtine has exited to the top of the method in a defer
statement. This cleans up some duplicate code and also adheres to the
pattern of using defers to signal cleaning up any dependent goroutine
state on exit.
2018-08-25 17:30:02 -07:00
Olaoluwa Osuntokun
a7656454aa
peer: stop chanMsg streams in defer right after creation 2018-08-25 17:29:59 -07:00
Olaoluwa Osuntokun
ce115a6a59 peer: raise readHandler wait group done to defer statement
In this commit, we raise the readHandler wait group done into a defer
statement at the top of the method. This fixes an existing but that
would cause the readHandler to declare it had exited, yet possibly still
be waiting on the chan message stream below to exit.
2018-08-24 18:53:28 -07:00