cargo fmt

This commit is contained in:
rachel-rose
2021-06-07 11:42:59 +02:00
parent dd21e0a9f3
commit c9796207d0
5 changed files with 31 additions and 27 deletions

View File

@@ -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::<Slab>().await?;
let tx = tx::Transaction::decode(&slab.get_payload()[..])?;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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<PathBuf> {
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<u8>) -> 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<u8>) -> 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() {}
}

View File

@@ -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<String, String> {
// 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<String, String> {
// 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<PathBuf> {
let path = dirs::home_dir()
.expect("cannot find home directory.")