Эх сурвалжийг харах

Move client module to src root.

parazyd 4 жил өмнө
parent
commit
24d7330f8f
3 өөрчлөгдсөн 63 нэмэгдсэн , 70 устгасан
  1. 62 10
      src/client.rs
  2. 0 60
      src/client/mod.rs
  3. 1 0
      todo.md

+ 62 - 10
src/client/client.rs → src/client.rs

@@ -1,3 +1,11 @@
+use async_executor::Executor;
+use async_std::sync::{Arc, Mutex};
+use bellman::groth16;
+use bls12_381::Bls12;
+use log::*;
+use std::net::SocketAddr;
+use std::path::PathBuf;
+
 use crate::{
     blockchain::{rocks::columns, Rocks, RocksColumn, Slab},
     crypto::{
@@ -16,16 +24,20 @@ use crate::{
     Result,
 };
 
-use super::ClientFailed;
-
-use async_executor::Executor;
-use bellman::groth16;
-use bls12_381::Bls12;
-
-use async_std::sync::{Arc, Mutex};
-use log::*;
-use std::net::SocketAddr;
-use std::path::PathBuf;
+#[derive(Debug)]
+pub enum ClientFailed {
+    NotEnoughValue(u64),
+    InvalidAddress(String),
+    InvalidAmount(u64),
+    UnableToGetDepositAddress,
+    UnableToGetWithdrawAddress,
+    DoesNotHaveCashierPublicKey,
+    DoesNotHaveKeypair,
+    EmptyPassword,
+    WalletInitialized,
+    KeyExists,
+    ClientError(String),
+}
 
 pub struct Client {
     pub state: Arc<Mutex<State>>,
@@ -413,3 +425,43 @@ impl State {
         }
     }
 }
+
+impl std::error::Error for ClientFailed {}
+
+impl std::fmt::Display for ClientFailed {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        match self {
+            ClientFailed::NotEnoughValue(i) => {
+                write!(f, "There is no enough value {}", i)
+            }
+            ClientFailed::InvalidAddress(i) => {
+                write!(f, "Invalid Address {}", i)
+            }
+            ClientFailed::InvalidAmount(i) => {
+                write!(f, "Invalid Amount {}", i)
+            }
+            ClientFailed::UnableToGetDepositAddress => f.write_str("Unable to get deposit address"),
+            ClientFailed::UnableToGetWithdrawAddress => {
+                f.write_str("Unable to get withdraw address")
+            }
+            ClientFailed::DoesNotHaveCashierPublicKey => {
+                f.write_str("Does not have cashier public key")
+            }
+            ClientFailed::DoesNotHaveKeypair => f.write_str("Does not have keypair"),
+            ClientFailed::EmptyPassword => f.write_str("Password is empty. Cannot create database"),
+            ClientFailed::WalletInitialized => f.write_str("Wallet already initalized"),
+            ClientFailed::KeyExists => f.write_str("Keypair already exists"),
+            ClientFailed::ClientError(i) => {
+                write!(f, "ClientError: {}", i)
+            }
+        }
+    }
+}
+
+impl From<super::error::Error> for ClientFailed {
+    fn from(err: super::error::Error) -> ClientFailed {
+        ClientFailed::ClientError(err.to_string())
+    }
+}
+
+pub type ClientResult<T> = std::result::Result<T, ClientFailed>;

+ 0 - 60
src/client/mod.rs

@@ -1,60 +0,0 @@
-pub mod client;
-
-pub use client::{Client, State};
-
-use std::fmt;
-
-#[derive(Debug)]
-pub enum ClientFailed {
-    NotEnoughValue(u64),
-    InvalidAddress(String),
-    InvalidAmount(u64),
-    UnableToGetDepositAddress,
-    UnableToGetWithdrawAddress,
-    DoesNotHaveCashierPublicKey,
-    DoesNotHaveKeypair,
-    EmptyPassword,
-    WalletInitialized,
-    KeyExists,
-    ClientError(String),
-}
-
-impl std::error::Error for ClientFailed {}
-
-impl fmt::Display for ClientFailed {
-    fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result {
-        match self {
-            ClientFailed::NotEnoughValue(i) => {
-                write!(f, "There is no enough value {}", i)
-            }
-            ClientFailed::InvalidAddress(i) => {
-                write!(f, "Invalid Address {}", i)
-            }
-            ClientFailed::InvalidAmount(i) => {
-                write!(f, "Invalid Amount {}", i)
-            }
-            ClientFailed::UnableToGetDepositAddress => f.write_str("Unable to get deposit address"),
-            ClientFailed::UnableToGetWithdrawAddress => {
-                f.write_str("Unable to get withdraw address")
-            }
-            ClientFailed::DoesNotHaveCashierPublicKey => {
-                f.write_str("Does not have cashier public key")
-            }
-            ClientFailed::DoesNotHaveKeypair => f.write_str("Does not have keypair"),
-            ClientFailed::EmptyPassword => f.write_str("Password is empty. Cannot create database"),
-            ClientFailed::WalletInitialized => f.write_str("Wallet already initalized"),
-            ClientFailed::KeyExists => f.write_str("Keypair already exists"),
-            ClientFailed::ClientError(i) => {
-                write!(f, "ClientError: {}", i)
-            }
-        }
-    }
-}
-
-impl From<super::error::Error> for ClientFailed {
-    fn from(err: super::error::Error) -> ClientFailed {
-        ClientFailed::ClientError(err.to_string())
-    }
-}
-
-pub type ClientResult<T> = std::result::Result<T, ClientFailed>;

+ 1 - 0
todo.md

@@ -3,6 +3,7 @@
 ## misc
 
 - [ ] sqlcipher: better document install process or otherwise remove friction of using bundled version
+- [ ] git grep TODO
 
 ## v0-release