Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/rust-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Start Docker Compose services
run: |
cd testing
nohup /bin/sh -c 'docker compose up -d --build --wait; touch ./compose-ready' > compose.log 2>&1 &
nohup /bin/sh -c 'docker compose --env-file ./testing.env up -d --build --wait; touch ./compose-ready' > compose.log 2>&1 &
cd ..

- name: Rust cache
Expand Down Expand Up @@ -57,14 +57,14 @@ jobs:
exit 1
fi

. ./.env && docker network connect $SERVICES_NETWORK_NAME $(hostname)
. ./testing.env && docker network connect $SERVICES_NETWORK_NAME $(hostname)
cd ..

- name: Run tests
run: |
cp testing/.env .
cp testing/testing.env ./testing.env
cargo test

- name: Stop Docker Compose services
if: always()
run: docker compose -f testing/docker-compose.yml down -v
run: docker compose --env-file testing/testing.env -f testing/docker-compose.yml down -v
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/.env
**/.idea/
**/target/
**/.DS_Store
testing.env
113 changes: 77 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[workspace]
members = [
"components",
"migration",
"pingora",
"server",
"service",
"pingora",
"testing",
"migration",
"switchgear"
"service-api",
"switchgear",
"testing"
]

resolver = "2"
Expand All @@ -14,15 +16,16 @@ resolver = "2"
version = "0.1.23"

[workspace.dependencies]
switchgear-components = { version = "0.1.23", path = "components" }
switchgear-migration = { version = "0.1.23", path = "migration" }
switchgear-pingora = { version = "0.1.23", path = "pingora" }
switchgear-service = { version = "0.1.23", path = "service" }
switchgear-migration = { version = "0.1.23", path = "migration" }
switchgear-service-api = { version = "0.1.23", path = "service-api" }
switchgear-testing = { version = "0.1.23", path = "testing" }


[profile.release]
lto = true
codegen-units = 1
lto = true
panic = 'abort'
strip = true

Expand Down
31 changes: 0 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1235,34 +1235,3 @@ Metadata can include images in PNG or JPEG format, base64 encoded:
Metadata identifiers can be:
- Email: `{"email": "contact@example.com"}`
- Text: `{"text": "contact@example.com"}`

## SDK

### Service

The [switchgear-service](./service) crate defines all services and their trait dependencies. See the `api` module for trait definitions and data models: [service/src/api](./service/src/api)

![image](./doc/service_traits_component_diagram-Service_Layer_Trait_Relationships.png)


### Pingora

`PingoraLnBalancer` is the default `LnBalancer` implementation. The [switchgear-pingora](./pingora) crate holds the complete implementation, plus trait definitions it uses for itself.

![image](./doc/pingora_traits_component_diagram-PingoraLnBalancer_Trait_Dependencies.png)


### Components

The `components` module in [switchgear-service](./service/src/components) is a collection self-defined traits and implementations useful for implementing a complete `LnBalancer`. The module also holds different implementations of `DiscoveryBackendStore`, `OfferStore` and `OfferMetadataStore`.

#### Service Components

![image](./doc/service_components_traits_diagram-Service_Components_Trait_Dependencies.png)

#### Data Store Implementations

![image](./doc/service_discovery_traits_diagram-Discovery_Components_Trait_Dependencies.png)

![image](./doc/service_offer_traits_diagram-Offer_Components_Trait_Dependencies.png)

55 changes: 55 additions & 0 deletions components/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "switchgear-components"
version.workspace = true
edition = "2021"
authors = ["Bitshock <info@bitshock.com>"]
description = "Component APIs and implementations for Switchgear LNURL load balancer"
documentation = "https://github.com/bitshock-src/switchgear"
homepage = "https://bitshock.com"
repository = "https://github.com/bitshock-src/switchgear"
license = "Apache-2.0"
keywords = ["bitcoin", "lightning", "lnurl", "api", "service"]
categories = ["network-programming", "web-programming", "cryptography::cryptocurrencies"]
publish = true

[dependencies]
async-trait = "0.1"
axum = { version = "0.8", features = ["macros"] }
base64 = "0.22"
chrono = { version = "0.4", features = ["serde"] }
client-ip = { version = "0.1", features = ["forwarded-header"] }
hex = "0.4"
jsonwebtoken = { version = "10", features = ["aws_lc_rs"] }
log = "0.4"
prost = { version = "0.14" }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls-native-roots-no-provider"] }
rustls = { version = "0.23", default-features = false }
sea-orm = { version = "1", default-features = false, features = ["with-chrono", "with-uuid", "with-json"] }
secp256k1 = { version = "0.31", features = ["recovery", "serde"] }
serde = "1"
serde_json = "1"
sha2 = "0.10"
sqlx = { version = "0.8", default-features = false, features = ["runtime-tokio", "tls-rustls-aws-lc-rs", "sqlite", "postgres", "mysql"] }
switchgear-migration.workspace = true
switchgear-service-api.workspace = true
tempfile = "3"
thiserror = "2"
tokio = { version = "1", features = ["full"] }
tonic = { version = "0.14", default-features = false, features = ["codegen", "transport", "tls-native-roots"] }
tonic-prost = "0.14"
tower = { version = "0.5", features = ["balance"] }
url = { version = "2", features = ["serde"] }
uuid = { version = "1", features = ["v4", "serde"] }

[build-dependencies]
tonic-prost-build = { version = "0.14" }

[dev-dependencies]
anyhow = "1"
bitcoin_hashes = "0.14"
lightning-invoice = { version = "0.34", features = ["serde", "std"] }
p256 = { version = "0.13", features = ["ecdsa"] }
pkcs8 = { version = "0.10", features = ["pem"] }
rand = "0.8"
rustls = { version = "0.23", features = ["aws-lc-rs"] }
switchgear-testing.workspace = true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading