From 24d7330f8f0d7ea972b48ce13860dc452e230506 Mon Sep 17 00:00:00 2001 From: parazyd Date: Fri, 1 Oct 2021 14:16:36 +0200 Subject: [PATCH] Move client module to src root. --- src/{client => }/client.rs | 72 ++++++++++++++++++++++++++++++++------ src/client/mod.rs | 60 ------------------------------- todo.md | 1 + 3 files changed, 63 insertions(+), 70 deletions(-) rename src/{client => }/client.rs (87%) delete mode 100644 src/client/mod.rs diff --git a/src/client/client.rs b/src/client.rs similarity index 87% rename from src/client/client.rs rename to src/client.rs index c2ce3f35e..b8468a445 100644 --- a/src/client/client.rs +++ b/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>, @@ -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 for ClientFailed { + fn from(err: super::error::Error) -> ClientFailed { + ClientFailed::ClientError(err.to_string()) + } +} + +pub type ClientResult = std::result::Result; diff --git a/src/client/mod.rs b/src/client/mod.rs deleted file mode 100644 index 2911967fa..000000000 --- a/src/client/mod.rs +++ /dev/null @@ -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 for ClientFailed { - fn from(err: super::error::Error) -> ClientFailed { - ClientFailed::ClientError(err.to_string()) - } -} - -pub type ClientResult = std::result::Result; diff --git a/todo.md b/todo.md index 6ef24930f..a937ed5b6 100644 --- a/todo.md +++ b/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