Skip to content

Commit

Permalink
address new comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bonez committed Nov 29, 2020
1 parent 3274c06 commit da8d466
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 0 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions src/create_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<State, Error> {
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,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(feature = "old_rust", allow(unstable_name_collisions))]

#[macro_use]
extern crate derive_more;
#[macro_use]
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[macro_use]
#![type_length_limit = "1630928"]

extern crate configure_me;
#[macro_use]
extern crate serde;
Expand Down
3 changes: 3 additions & 0 deletions src/rpc_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<T> 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> {
Expand All @@ -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
Expand Down

0 comments on commit da8d466

Please sign in to comment.