From c9796207d09b6d8d8b10adfa49a12bc2cac9f90a Mon Sep 17 00:00:00 2001 From: rachel-rose Date: Mon, 7 Jun 2021 11:42:59 +0200 Subject: [PATCH] cargo fmt --- src/bin/darkfid.rs | 3 +-- src/bin/tx-test.rs | 3 +-- src/lib.rs | 2 +- src/rpc/adapter.rs | 29 ++++++++++++++++++----------- src/wallet/walletdb.rs | 21 ++++++++++----------- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/bin/darkfid.rs b/src/bin/darkfid.rs index c04cf5a08..9a144f6c6 100644 --- a/src/bin/darkfid.rs +++ b/src/bin/darkfid.rs @@ -14,8 +14,8 @@ use drk::crypto::{ }; use drk::serial::Decodable; use drk::service::{ClientProgramOptions, GatewayClient, Subscriber}; -use drk::wallet::WalletDB; use drk::state::{state_transition, ProgramState, StateUpdate}; +use drk::wallet::WalletDB; use drk::{tx, Result}; use async_executor::Executor; @@ -138,7 +138,6 @@ pub async fn subscribe( mut state: State, ) -> Result<()> { loop { - let slab = subscriber.fetch::().await?; let tx = tx::Transaction::decode(&slab.get_payload()[..])?; diff --git a/src/bin/tx-test.rs b/src/bin/tx-test.rs index fe6944981..0ed8de606 100644 --- a/src/bin/tx-test.rs +++ b/src/bin/tx-test.rs @@ -8,8 +8,8 @@ use rand::rngs::OsRng; //use rocksdb::DB; use rusqlite::{named_params, Connection}; //use std::fs::File; -use std::path::Path; use rocksdb::{IteratorMode, Options, DB}; +use std::path::Path; use drk::crypto::{ coin::Coin, @@ -162,7 +162,6 @@ impl MemoryState { // We weren't able to decrypt the note with any of our keys. None } - } fn main() { diff --git a/src/lib.rs b/src/lib.rs index ecb7ab61e..bd3277e41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ use bls12_381::{Bls12, Scalar}; use std::collections::{HashMap, HashSet}; pub mod async_serial; +pub mod blockchain; pub mod bls_extensions; pub mod circuit; pub mod crypto; @@ -16,7 +17,6 @@ pub mod net; pub mod rpc; pub mod serial; pub mod service; -pub mod blockchain; pub mod state; pub mod system; pub mod tx; diff --git a/src/rpc/adapter.rs b/src/rpc/adapter.rs index 252345d32..0811d8cf3 100644 --- a/src/rpc/adapter.rs +++ b/src/rpc/adapter.rs @@ -1,8 +1,8 @@ -use std::path::{Path, PathBuf}; -use log::*; -use std::sync::Arc; use crate::wallet::WalletDB; use crate::{Error, Result}; +use log::*; +use std::path::{Path, PathBuf}; +use std::sync::Arc; // Dummy adapter for now pub struct RpcAdapter {} @@ -22,39 +22,47 @@ impl RpcAdapter { pub async fn key_gen() -> Result { debug!(target: "adapter", "key_gen() [START]"); - let path = Self::get_path("wallet.db").await.expect("Failed to get path"); + let path = Self::get_path("wallet.db") + .await + .expect("Failed to get path"); //WalletDB::key_gen(path).await?; Ok(path) } pub async fn new_wallet() -> Result<()> { debug!(target: "adapter", "new_wallet() [START]"); - let path = Self::get_path("wallet.db").await.expect("Failed to get path"); + let path = Self::get_path("wallet.db") + .await + .expect("Failed to get path"); WalletDB::new(path).await?; Ok(()) } pub async fn new_cashier_wallet() -> Result<()> { debug!(target: "adapter", "new_cashier_wallet() [START]"); - let path = Self::get_path("cashier.db").await.expect("Failed to get path"); + let path = Self::get_path("cashier.db") + .await + .expect("Failed to get path"); WalletDB::new(path).await?; Ok(()) } pub async fn save_cash_key(pubkey: Vec) -> Result<()> { debug!(target: "adapter", "save_cash_key() [START]"); - let path = Self::get_path("cashier.db").await.expect("Failed to get path"); + let path = Self::get_path("cashier.db") + .await + .expect("Failed to get path"); WalletDB::save(path, pubkey).await?; Ok(()) - } pub async fn save_key(pubkey: Vec) -> Result<()> { debug!(target: "adapter", "save_key() [START]"); - let path = Self::get_path("wallet.db").await.expect("Failed to get path"); + let path = Self::get_path("wallet.db") + .await + .expect("Failed to get path"); WalletDB::save(path, pubkey).await?; Ok(()) - } pub async fn get_info() {} @@ -63,4 +71,3 @@ impl RpcAdapter { pub async fn stop() {} } - diff --git a/src/wallet/walletdb.rs b/src/wallet/walletdb.rs index 3e4437706..367519ad2 100644 --- a/src/wallet/walletdb.rs +++ b/src/wallet/walletdb.rs @@ -1,15 +1,14 @@ -use crate::Result; use crate::serial; +use crate::Result; use ff::Field; use log::*; use rand::rngs::OsRng; -use rusqlite::{Connection, named_params}; +use rusqlite::{named_params, Connection}; use std::path::PathBuf; // TODO: make this more generic to remove boiler plate. e.g. create_wallet(cashier) instead of // create_cashier_wallet -pub struct WalletDB { -} +pub struct WalletDB {} impl WalletDB { pub async fn new(path: PathBuf) -> Result<()> { @@ -18,13 +17,13 @@ impl WalletDB { Ok(connect.execute_batch(&contents)?) } -// pub async fn create_keypair() -> Result { -// let public = zcash_primitives::constants::SPENDING_KEY_GENERATOR * secret; -// let pubkey = serial::serialize(&public); -// let secret: jubjub::Fr = jubjub::Fr::random(&mut OsRng); -// let privkey = serial::serialize(&secret); -// Ok(pubkey, privkey) -// } + // pub async fn create_keypair() -> Result { + // let public = zcash_primitives::constants::SPENDING_KEY_GENERATOR * secret; + // let pubkey = serial::serialize(&public); + // let secret: jubjub::Fr = jubjub::Fr::random(&mut OsRng); + // let privkey = serial::serialize(&secret); + // Ok(pubkey, privkey) + // } pub async fn path() -> Result { let path = dirs::home_dir() .expect("cannot find home directory.")