From da8d466e316d83d497fa268cc7963c5ab3bed2ae Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Sun, 29 Nov 2020 14:16:52 -0700 Subject: [PATCH] address new comments --- Cargo.toml | 2 +- src/client.rs | 3 --- src/create_state.rs | 14 +++++++++----- src/lib.rs | 2 ++ src/main.rs | 3 ++- src/rpc_methods.rs | 3 +++ src/util.rs | 4 ++-- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f3f11f9..84cbd56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ name = "btc_rpc_proxy" path = "src/lib.rs" [[bin]] -name = "btc-rpc-proxy" +name = "btc_rpc_proxy" path = "src/main.rs" [package.metadata.configure_me] diff --git a/src/client.rs b/src/client.rs index b8d5094..df4dbcb 100644 --- a/src/client.rs +++ b/src/client.rs @@ -16,9 +16,6 @@ use serde::{ }; use serde_json::Value; -#[cfg(feature = "old_rust")] -use crate::util::old_rust::StrCompat; - pub const MISC_ERROR_CODE: i64 = -1; pub const METHOD_NOT_ALLOWED_ERROR_CODE: i64 = -32604; pub const PARSE_ERROR_CODE: i64 = -32700; diff --git a/src/create_state.rs b/src/create_state.rs index 5d06c83..8463a98 100644 --- a/src/create_state.rs +++ b/src/create_state.rs @@ -6,13 +6,17 @@ use btc_rpc_proxy::{AuthSource, Peers, RpcClient, State, TorState, Users}; use slog::Drain; use tokio::sync::RwLock; -use config::ResultExt; - -include_config!(); +#[allow(dead_code)] +#[allow(unused_mut)] +#[allow(unused_variables)] +mod config { + include!(concat!(env!("OUT_DIR"), "/configure_me_config.rs")); +} +use self::config::{Config, ResultExt}; pub fn create_state() -> Result { - let (config, _) = config::Config::including_optional_config_files(std::iter::empty::<&str>()) - .unwrap_or_exit(); + let (config, _) = + Config::including_optional_config_files(std::iter::empty::<&str>()).unwrap_or_exit(); let auth = AuthSource::from_config( config.bitcoind_user, diff --git a/src/lib.rs b/src/lib.rs index 6e3efba..1c1170a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(feature = "old_rust", allow(unstable_name_collisions))] + #[macro_use] extern crate derive_more; #[macro_use] diff --git a/src/main.rs b/src/main.rs index ffd9953..4040af8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -#[macro_use] +#![type_length_limit = "1630928"] + extern crate configure_me; #[macro_use] extern crate serde; diff --git a/src/rpc_methods.rs b/src/rpc_methods.rs index c1d8e0f..3420356 100644 --- a/src/rpc_methods.rs +++ b/src/rpc_methods.rs @@ -11,6 +11,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use crate::client::RpcMethod; use crate::util::{Either, HexBytes}; +#[cfg(feature = "old_rust")] +use crate::util::old_rust::StrCompat; + #[derive(Debug)] pub struct GetBlock; #[derive(Debug, Deserialize, Serialize)] diff --git a/src/util.rs b/src/util.rs index 95d2578..f038698 100644 --- a/src/util.rs +++ b/src/util.rs @@ -53,7 +53,7 @@ impl ApplyMut for T {} pub mod old_rust { pub trait StrCompat { fn strip_prefix<'a>(&'a self, prefix: &str) -> Option<&'a str>; - fn strip_suffix<'a>(&'a self, prefix: &str) -> Option<&'a str>; + fn strip_suffix<'a>(&'a self, suffix: &str) -> Option<&'a str>; } impl StrCompat for str { fn strip_prefix<'a>(&'a self, prefix: &str) -> Option<&'a str> { @@ -64,7 +64,7 @@ pub mod old_rust { } } fn strip_suffix<'a>(&'a self, suffix: &str) -> Option<&'a str> { - if let Some(s) = self.rmatches(prefix).next() { + if let Some(s) = self.rmatches(suffix).next() { Some(&self[..(self.len() - s.len())]) } else { None