From 268fbf5c091e09bdcb9884e49c849f70a2497a5e Mon Sep 17 00:00:00 2001
From: Martin Habovstiak <martin.habovstiak@gmail.com>
Date: Fri, 6 Sep 2019 20:29:29 +0200
Subject: [PATCH] Added CWD cfg file and fixed ordering of cfg files

The values in user-level config file should override system config file,
not the other way arounnd. Also added `electrs.toml` config file which
is searched for in the current directory.
---
 src/config.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/config.rs b/src/config.rs
index f5b3e7a..6c055b8 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -143,8 +143,11 @@ impl Config {
 
         let system_config: &OsStr = "/etc/electrs/config.toml".as_ref();
         let home_config = home_dir().map(|mut dir| { dir.push(".electrs/config.toml"); dir });
-        let configs = std::iter::once(system_config)
-            .chain(home_config.as_ref().map(AsRef::as_ref));
+        let cwd_config: &OsStr = "electrs.toml".as_ref();
+        let configs = std::iter::once(cwd_config)
+            .chain(home_config.as_ref().map(AsRef::as_ref))
+            .chain(std::iter::once(system_config));
+
         let (mut config, _) = internal::Config::including_optional_config_files(configs).unwrap_or_exit();
 
         let network_name = match config.network {