From adf31b7e53e0fa4fb4471589190e11778b25dc72 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Wed, 25 Oct 2023 11:22:32 -0400 Subject: [PATCH] sim-lib: Get rid of nested json for node definition I must have been way more sleep-deprived than I thought when originally designing this, but we don't really need the nested json with node type tags to parse node information (as long as the node info has, **at least** one different field name). Mainly, this goes from: ```json "nodes": [ { "LND": { "id": "...", "address": "...", "macaroon": "...", "cert": "..." } }, { "CLN": { "id": "...", "address": "...", "ca_cert": "...", "client_cert": "...", "client_key": "..." } } ] ``` To: ```json "nodes": [ { "id": "...", "address": "...", "macaroon": "...", "cert": "..." }, { "id": "...", "address": "...", "ca_cert": "...", "client_cert": "...", "client_key": "..." } ] ``` --- README.md | 46 +++++++++++++++++++--------------------------- docker/README.md | 10 ++++------ sim-lib/src/lib.rs | 3 +-- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 138f5e7e..81737bca 100644 --- a/README.md +++ b/README.md @@ -70,21 +70,17 @@ not "drain" from the simulation. { "nodes": [ { - "LND": { - "id": "Alice", - "address": "https://localhost:10011", - "macaroon": "/path/admin.macaroon", - "cert": "/path/tls.cert" - } + "id": "Alice", + "address": "https://localhost:10011", + "macaroon": "/path/admin.macaroon", + "cert": "/path/tls.cert" }, - { - "CLN": { - "id": "0230a16a05c5ca120136b3a770a2adfdad88a68d526e63448a9eef88bddd6a30d8", - "address": "https://localhost:10013", - "ca_cert": "/path/ca.pem", - "client_cert": "/path/client.pem", - "client_key": "/path/client-key.pem" - } + { + "id": "0230a16a05c5ca120136b3a770a2adfdad88a68d526e63448a9eef88bddd6a30d8", + "address": "https://localhost:10013", + "ca_cert": "/path/ca.pem", + "client_cert": "/path/client.pem", + "client_key": "/path/client-key.pem" } ] } @@ -124,21 +120,17 @@ The example simulation file below sets up the following simulation: { "nodes": [ { - "LND": { - "id": "Alice", - "address": "https://localhost:10011", - "macaroon": "/path/admin.macaroon", - "cert": "/path/tls.cert" - } + "id": "Alice", + "address": "https://localhost:10011", + "macaroon": "/path/admin.macaroon", + "cert": "/path/tls.cert" }, { - "CLN": { - "id": "0230a16a05c5ca120136b3a770a2adfdad88a68d526e63448a9eef88bddd6a30d8", - "address": "https://localhost:10013", - "ca_cert": "/path/ca.pem", - "client_cert": "/path/client.pem", - "client_key": "/path/client-key.pem" - } + "id": "0230a16a05c5ca120136b3a770a2adfdad88a68d526e63448a9eef88bddd6a30d8", + "address": "https://localhost:10013", + "ca_cert": "/path/ca.pem", + "client_cert": "/path/client.pem", + "client_key": "/path/client-key.pem" } ], "activity": [ diff --git a/docker/README.md b/docker/README.md index 07a22191..19500934 100644 --- a/docker/README.md +++ b/docker/README.md @@ -51,12 +51,10 @@ For instance, in your configuration: ```json { - "LND": { - "id": "022579561f6f0ea86e330df2f9e7b2be3e0a53f8552f9d5293b80dfc1038f2f66d", - "address": "https://host.docker.internal:10002", - "macaroon": "/path/in/container/lnd/bob/data/chain/bitcoin/regtest/admin.macaroon", - "cert": "/path/in/container/lnd/bob/tls.cert" - } + "id": "022579561f6f0ea86e330df2f9e7b2be3e0a53f8552f9d5293b80dfc1038f2f66d", + "address": "https://host.docker.internal:10002", + "macaroon": "/path/in/container/lnd/bob/data/chain/bitcoin/regtest/admin.macaroon", + "cert": "/path/in/container/lnd/bob/tls.cert" } ``` diff --git a/sim-lib/src/lib.rs b/sim-lib/src/lib.rs index c572e955..f6110a25 100644 --- a/sim-lib/src/lib.rs +++ b/sim-lib/src/lib.rs @@ -25,10 +25,9 @@ mod random_activity; mod serializers; #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(untagged)] pub enum NodeConnection { - #[serde(alias = "lnd", alias = "Lnd")] LND(lnd::LndConnection), - #[serde(alias = "cln", alias = "Cln")] CLN(cln::ClnConnection), }