Skip to content

Commit 9e80b90

Browse files
committed
Implement lightning-net
Squashed commits in original PR at lexe-app#1: - Create empty lightning-net module - SyncSocketDescriptor skeleton implementation - Connection struct with read and write halves - Implement shutdown() for TcpReader and TcpWriter - Implement most of spawn_inbound_handler - Add crossbeam and some associated channels - Implement basic functionality of ConnectionWriter - Pass a Arc<PeerManager> into ConnectionReader - Get a SyncSocketDescriptor into the ConnectionWriter - Implement first half of pausing reads - Renome write tx/rx to write_data tx/rx - Rename ConnectionReader/Writer to Reader/Writer - Create the Reader/Writer cmd channels - Send ResumeRead command to the Reader - Remove write_cmd, rename reader_cmd -> resume_read - Reader can handle ResumeRead events - Implement disconnecting from peer - send_data() actually sends data now - Allow send_data() to pause reads - Get a Arc<PeerManager> into Writer - Refactor write_data tx/rx into writer_cmd tx/rx - Give Reader/Writer a cmd tx for the other - Implement all disconnecting except TcpDisconnectooor - Remove the Arc<Mutex<Connection>> - Refactor Connection into setup() - disconnect_socket() now calls into TcpDisconnectooor - Get a SyncSocketDescriptor into Writer - Call write_buffer_space_avail and socket_disconnected v2 - resume_read check should go before the early return - Handle read() ErrorKind variants - Implement handle_connection and initiate_outbound - Finish writing doc comments, clean up - Basic tests for lightning-net - These is modeled exactly after the tests in lightning-net-tokio - Update GitHub CI and dependabot for lightning-net - Reduce the dependencies used - Implementing PR review feedback from @phlip9 - Remove some comments about SGX - Hide ID_COUNTER in a function, return JoinHandles - Reader/Writer now send commands via the descriptor - Extract do_recv(), do_try_recv(), do_read() fns v2 - Split WriteData command into its own channel v4 - Remove `std::net` limitations from EDP doc comment - Implement ReaderState enum v2
1 parent 6592081 commit 9e80b90

File tree

5 files changed

+1129
-1
lines changed

5 files changed

+1129
-1
lines changed

.github/dependabot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ updates:
1818
directory: "/lightning-invoice"
1919
schedule:
2020
interval: "daily"
21+
- package-ecosystem: "cargo"
22+
directory: "/lightning-net"
23+
schedule:
24+
interval: "daily"
2125
- package-ecosystem: "cargo"
2226
directory: "/lightning-net-tokio"
2327
schedule:

.github/workflows/build.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
platform: [ ubuntu-latest ]
1111
toolchain: [ stable,
1212
beta,
13-
# 1.41.1 is MSRV for Rust-Lightning, lightning-invoice, and lightning-persister
13+
# 1.41.1 is MSRV for Rust-Lightning, lightning-invoice, lightning-persister, lightning-net, and lightning-background-processor
1414
1.41.1,
1515
# 1.45.2 is MSRV for lightning-net-tokio, lightning-block-sync, and coverage generation
1616
1.45.2,
@@ -74,6 +74,7 @@ jobs:
7474
cargo build --verbose --color always -p lightning
7575
cargo build --verbose --color always -p lightning-invoice
7676
cargo build --verbose --color always -p lightning-persister
77+
cargo build --verbose --color always -p lightning-net
7778
- name: Build on Rust ${{ matrix.toolchain }} with all Log-Limiting features
7879
if: matrix.test-log-variants
7980
run: |
@@ -142,13 +143,15 @@ jobs:
142143
cargo test --verbose --color always -p lightning
143144
cargo test --verbose --color always -p lightning-invoice
144145
cargo build --verbose --color always -p lightning-persister
146+
cargo build --verbose --color always -p lightning-net
145147
cargo build --verbose --color always -p lightning-background-processor
146148
- name: Test C Bindings Modifications on Rust ${{ matrix.toolchain }}
147149
if: "! matrix.build-net-tokio"
148150
run: |
149151
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always -p lightning
150152
RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always -p lightning-invoice
151153
RUSTFLAGS="--cfg=c_bindings" cargo build --verbose --color always -p lightning-persister
154+
RUSTFLAGS="--cfg=c_bindings" cargo build --verbose --color always -p lightning-net
152155
RUSTFLAGS="--cfg=c_bindings" cargo build --verbose --color always -p lightning-background-processor
153156
- name: Test Block Sync Clients on Rust ${{ matrix.toolchain }} with features
154157
if: "matrix.build-net-tokio && !matrix.coverage"

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"lightning",
55
"lightning-block-sync",
66
"lightning-invoice",
7+
"lightning-net",
78
"lightning-net-tokio",
89
"lightning-persister",
910
"lightning-background-processor",

lightning-net/Cargo.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "lightning-net"
3+
version = "0.0.106"
4+
authors = ["Max Fang <[email protected]>"]
5+
license = "MIT OR Apache-2.0"
6+
repository = "https://github.com/lightningdevkit/rust-lightning/"
7+
description = """
8+
Implementation of the rust-lightning network stack for a synchronous runtime.
9+
For Rust-Lightning clients which wish to make direct connections to Lightning
10+
P2P nodes, this is a simple alternative to implementing the required network
11+
stack for those who do not want to use async Rust or Tokio.
12+
"""
13+
edition = "2018"
14+
15+
[package.metadata.docs.rs]
16+
all-features = true
17+
rustdoc-args = ["--cfg", "docsrs"]
18+
19+
[dependencies]
20+
bitcoin = "0.28.1"
21+
lightning = { version = "0.0.106", path = "../lightning" }
22+
crossbeam-channel = "0.5.4"

0 commit comments

Comments
 (0)