Skip to content

Commit

Permalink
sim-lib: Get rid of nested json for node definition
Browse files Browse the repository at this point in the history
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": "..."
    }
]
```
  • Loading branch information
sr-gi committed Oct 25, 2023
1 parent 3001a22 commit adf31b7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 35 deletions.
46 changes: 19 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down Expand Up @@ -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": [
Expand Down
10 changes: 4 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```

Expand Down
3 changes: 1 addition & 2 deletions sim-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down

0 comments on commit adf31b7

Please sign in to comment.