gui: clippification
This commit is contained in:
parent
8b4866158b
commit
6871407b1a
@ -1,15 +1,7 @@
|
||||
use crate::daemon::model::Coin;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Cache {
|
||||
pub blockheight: i32,
|
||||
pub coins: Vec<Coin>,
|
||||
}
|
||||
|
||||
impl Default for Cache {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
blockheight: 0,
|
||||
coins: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ impl App {
|
||||
self.cache.coins = coins.clone();
|
||||
}
|
||||
Message::BlockHeight(Ok(blockheight)) => {
|
||||
self.cache.blockheight = blockheight.clone();
|
||||
self.cache.blockheight = *blockheight;
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
@ -31,7 +31,7 @@ pub struct Home {
|
||||
}
|
||||
|
||||
impl Home {
|
||||
pub fn new(coins: &Vec<Coin>) -> Self {
|
||||
pub fn new(coins: &[Coin]) -> Self {
|
||||
Self {
|
||||
balance: Amount::from_sat(coins.iter().map(|coin| coin.amount.as_sat()).sum()),
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ use crate::ui::component::text::*;
|
||||
|
||||
use super::message::Message;
|
||||
|
||||
pub fn home_view<'a>(balance: &'a bitcoin::Amount) -> Element<'a, Message> {
|
||||
pub fn home_view(balance: &bitcoin::Amount) -> Element<Message> {
|
||||
column()
|
||||
.push(column().padding(40))
|
||||
.push(text(&format!("{} BTC", balance.as_btc())).bold().size(50))
|
||||
|
||||
@ -92,7 +92,7 @@ impl error::Error for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
/// A JSONRPC error object
|
||||
pub struct RpcError {
|
||||
/// The integer identifier of the error
|
||||
|
||||
@ -113,7 +113,7 @@ impl JsonRPCClient {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
/// A JSONRPC request object
|
||||
pub struct Request<'f, T: Serialize> {
|
||||
/// The name of the RPC call
|
||||
@ -126,7 +126,7 @@ pub struct Request<'f, T: Serialize> {
|
||||
pub jsonrpc: &'f str,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
/// A JSONRPC response object
|
||||
pub struct Response<T> {
|
||||
/// A result if there is one, or null
|
||||
@ -243,7 +243,7 @@ impl From<Error> for super::DaemonError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
/// A JSONRPC error object
|
||||
pub struct RpcError {
|
||||
/// The integer identifier of the error
|
||||
|
||||
@ -306,9 +306,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_parse_args() {
|
||||
assert_eq!(true, parse_args(vec!["--meth".into()]).is_err());
|
||||
assert_eq!(true, parse_args(vec!["--datadir".into()]).is_err());
|
||||
assert_eq!(true, parse_args(vec!["--conf".into()]).is_err());
|
||||
assert!(parse_args(vec!["--meth".into()]).is_err());
|
||||
assert!(parse_args(vec!["--datadir".into()]).is_err());
|
||||
assert!(parse_args(vec!["--conf".into()]).is_err());
|
||||
assert_eq!(
|
||||
Some(vec![
|
||||
Arg::DatadirPath(PathBuf::from(".")),
|
||||
@ -316,7 +316,7 @@ mod tests {
|
||||
]),
|
||||
parse_args(
|
||||
"--datadir . --conf hello.toml"
|
||||
.split(" ")
|
||||
.split(' ')
|
||||
.map(|a| a.to_string())
|
||||
.collect()
|
||||
)
|
||||
@ -333,7 +333,7 @@ mod tests {
|
||||
]),
|
||||
parse_args(
|
||||
"--datadir hello --testnet"
|
||||
.split(" ")
|
||||
.split(' ')
|
||||
.map(|a| a.to_string())
|
||||
.collect()
|
||||
)
|
||||
@ -346,7 +346,7 @@ mod tests {
|
||||
]),
|
||||
parse_args(
|
||||
"--testnet --datadir hello"
|
||||
.split(" ")
|
||||
.split(' ')
|
||||
.map(|a| a.to_string())
|
||||
.collect()
|
||||
)
|
||||
|
||||
@ -9,9 +9,11 @@ use std::sync::{
|
||||
};
|
||||
use std::thread;
|
||||
|
||||
type TransportReceiver = Receiver<Result<Value, DaemonError>>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DaemonClient {
|
||||
transport: Mutex<(Sender<Value>, Receiver<Result<Value, DaemonError>>)>,
|
||||
transport: Mutex<(Sender<Value>, TransportReceiver)>,
|
||||
}
|
||||
|
||||
impl Client for DaemonClient {
|
||||
|
||||
@ -13,7 +13,7 @@ pub struct Sandbox<S: State> {
|
||||
|
||||
impl<S: State + Send + 'static> Sandbox<S> {
|
||||
pub fn new(state: S) -> Self {
|
||||
return Self { state };
|
||||
Self { state }
|
||||
}
|
||||
|
||||
pub fn state(&self) -> &S {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user