From 4b461781e55e1bc95ad1cd00b445bfad9c4d9b0d Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sun, 2 Jun 2024 22:53:19 +0200 Subject: [PATCH 1/3] Add --http-port to settings yaml --- src/settings.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/settings.rs b/src/settings.rs index 436fb1acf7..d084d6580d 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -17,6 +17,7 @@ pub struct Settings { first_inscription_height: Option, height_limit: Option, hidden: Option>, + http_port: Option, index: Option, index_addresses: bool, index_cache_size: Option, @@ -133,6 +134,7 @@ impl Settings { .cloned() .collect(), ), + http_port: self.http_port.or(source.http_port), index: self.index.or(source.index), index_addresses: self.index_addresses || source.index_addresses, index_cache_size: self.index_cache_size.or(source.index_cache_size), @@ -169,6 +171,7 @@ impl Settings { first_inscription_height: options.first_inscription_height, height_limit: options.height_limit, hidden: None, + http_port: None, index: options.index, index_addresses: options.index_addresses, index_cache_size: options.index_cache_size, @@ -219,6 +222,14 @@ impl Settings { }) }; + let get_u16 = |key| { + env + .get(key) + .map(|int| int.parse::()) + .transpose() + .with_context(|| format!("failed to parse environment variable ORD_{key} as u16")) + }; + let get_u32 = |key| { env .get(key) @@ -226,6 +237,7 @@ impl Settings { .transpose() .with_context(|| format!("failed to parse environment variable ORD_{key} as u32")) }; + let get_usize = |key| { env .get(key) @@ -249,6 +261,7 @@ impl Settings { first_inscription_height: get_u32("FIRST_INSCRIPTION_HEIGHT")?, height_limit: get_u32("HEIGHT_LIMIT")?, hidden: inscriptions("HIDDEN")?, + http_port: get_u16("HTTP_PORT")?, index: get_path("INDEX"), index_addresses: get_bool("INDEX_ADDRESSES"), index_cache_size: get_usize("INDEX_CACHE_SIZE")?, @@ -280,6 +293,7 @@ impl Settings { first_inscription_height: None, height_limit: None, hidden: None, + http_port: None, index: None, index_addresses: true, index_cache_size: None, @@ -354,6 +368,7 @@ impl Settings { }), height_limit: self.height_limit, hidden: self.hidden, + http_port: self.http_port, index: Some(index), index_addresses: self.index_addresses, index_cache_size: Some(match self.index_cache_size { @@ -1011,6 +1026,7 @@ mod tests { ("FIRST_INSCRIPTION_HEIGHT", "2"), ("HEIGHT_LIMIT", "3"), ("HIDDEN", "6fb976ab49dcec017f1e201e84395983204ae1a7c2abf7ced0a85d692e442799i0 703e5f7c49d82aab99e605af306b9a30e991e57d42f982908a962a81ac439832i0"), + ("HTTP_PORT", "8080"), ("INDEX", "index"), ("INDEX_CACHE_SIZE", "4"), ("INDEX_ADDRESSES", "1"), @@ -1056,6 +1072,7 @@ mod tests { .into_iter() .collect() ), + http_port: Some(8080), index: Some("index".into()), index_addresses: true, index_cache_size: Some(4), @@ -1091,6 +1108,7 @@ mod tests { "--datadir=/data/dir", "--first-inscription-height=2", "--height-limit=3", + "--http-port=8080", "--index-addresses", "--index-cache-size=4", "--index-runes", @@ -1120,6 +1138,7 @@ mod tests { first_inscription_height: Some(2), height_limit: Some(3), hidden: None, + http_port: Some(8080), index: Some("index".into()), index_addresses: true, index_cache_size: Some(4), From 4991332983c5cc378ffb6a4229c1a7bd8696ca09 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sun, 2 Jun 2024 22:58:42 +0200 Subject: [PATCH 2/3] Amend --- src/settings.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/settings.rs b/src/settings.rs index d084d6580d..2c1f60db9b 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1108,7 +1108,6 @@ mod tests { "--datadir=/data/dir", "--first-inscription-height=2", "--height-limit=3", - "--http-port=8080", "--index-addresses", "--index-cache-size=4", "--index-runes", @@ -1138,7 +1137,7 @@ mod tests { first_inscription_height: Some(2), height_limit: Some(3), hidden: None, - http_port: Some(8080), + http_port: None, index: Some("index".into()), index_addresses: true, index_cache_size: Some(4), From dc97fc48c58b054d73f2892bd31635726f8c50e2 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sun, 2 Jun 2024 23:03:34 +0200 Subject: [PATCH 3/3] Amend --- tests/settings.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/settings.rs b/tests/settings.rs index bfeeb51329..da228f2176 100644 --- a/tests/settings.rs +++ b/tests/settings.rs @@ -20,6 +20,7 @@ fn default() { "first_inscription_height": 767430, "height_limit": null, "hidden": \[\], + "http_port": null, "index": ".*index\.redb", "index_addresses": false, "index_cache_size": \d+,