Skip to content

Commit 72a5400

Browse files
committed
review: Small nits, documentation, and fixups
Small review items that are noncontroversial and can be rolled into a single commit.
1 parent 18641e8 commit 72a5400

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lightning/src/ln/peers/handler.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ use ln::peers::transport::{PayloadQueuer, Transport};
4343
use bitcoin::hashes::core::iter::Filter;
4444
use std::collections::hash_map::IterMut;
4545

46-
const MSG_BUFF_SIZE: usize = 10;
46+
// Number of items that can exist in the OutboundQueue before Sync message flow control is triggered
47+
const OUTBOUND_QUEUE_SIZE: usize = 10;
4748

4849
/// Interface PeerManager uses to interact with the Transport object
4950
pub(super) trait ITransport: MessageQueuer {
@@ -65,7 +66,7 @@ pub(super) trait ITransport: MessageQueuer {
6566
/// Returns the node_id of the remote node. Panics if not connected.
6667
fn get_their_node_id(&self) -> PublicKey;
6768

68-
/// Returns all Messages that have been received and can be parsed by the Transport
69+
/// Returns all Messages that have been received and can be successfully parsed by the Transport
6970
fn drain_messages<L: Deref>(&mut self, logger: L) -> Result<Vec<Message>, PeerHandleError> where L::Target: Logger;
7071
}
7172

@@ -77,7 +78,8 @@ pub(super) trait MessageQueuer {
7778
fn enqueue_message<M: Encode + Writeable, Q: PayloadQueuer, L: Deref>(&mut self, message: &M, output_buffer: &mut Q, logger: L) where L::Target: Logger;
7879
}
7980

80-
/// Trait representing a container that can try to flush data through a SocketDescriptor
81+
/// Trait representing a container that can try to flush data through a SocketDescriptor. Used by the
82+
/// PeerManager to handle flushing the outbound queue and flow control.
8183
pub(super) trait SocketDescriptorFlusher {
8284
/// Write previously enqueued data to the SocketDescriptor. A return of false indicates the
8385
/// underlying SocketDescriptor could not fulfill the send_data() call and the blocked state
@@ -198,7 +200,7 @@ impl<TransportImpl: ITransport> Peer<TransportImpl> {
198200
fn new(outbound: bool, transport: TransportImpl) -> Self {
199201
Self {
200202
outbound,
201-
outbound_queue: OutboundQueue::new(MSG_BUFF_SIZE),
203+
outbound_queue: OutboundQueue::new(OUTBOUND_QUEUE_SIZE),
202204
post_init_state: None,
203205
transport
204206
}

lightning/src/ln/peers/transport.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ pub trait IPeerHandshake {
2828
fn process_act(&mut self, input: &[u8]) -> Result<(Option<Vec<u8>>, Option<(Conduit, PublicKey)>), String>;
2929
}
3030

31-
/// Trait representing a container that allows enqueuing of Vec<[u8]>
31+
/// Trait representing a container that allows enqueuing of Vec<[u8]>. Used by Transport to enqueue
32+
/// NOISE handshake messages and post-NOISE encrypted Lightning Messages to be sent to a peer.
3233
pub(super) trait PayloadQueuer {
3334
/// Enqueue item to the queue
3435
fn push_back(&mut self, item: Vec<u8>);
@@ -40,6 +41,8 @@ pub(super) trait PayloadQueuer {
4041
fn queue_space(&self) -> usize;
4142
}
4243

44+
/// Used by the PeerManager to work with a BOLT8 authenticated transport layer. Abstracts the NOISE
45+
/// handshake as well as post-NOISE encrypted Lightning Message encryption/decryption.
4346
pub(super) struct Transport<PeerHandshakeImpl: IPeerHandshake=PeerHandshake> {
4447
pub(super) conduit: Option<Conduit>,
4548
handshake: PeerHandshakeImpl,

0 commit comments

Comments
 (0)