Просмотр исходного кода

renamed wallet adapter to adapters/user_adapter

lunar-mining 5 лет назад
Родитель
Сommit
39eaace8c9

+ 3 - 4
src/bin/darkfid.rs

@@ -1,6 +1,6 @@
 use drk::blockchain::{rocks::columns, Rocks, RocksColumn, Slab};
 use drk::cli::{Config, DarkfidCli, DarkfidConfig};
-use drk::cli::{TransferParams, WithdrawParams};
+use drk::cli::TransferParams;
 use drk::crypto::{
     load_params,
     merkle::{CommitmentTree, IncrementalWitness},
@@ -9,7 +9,7 @@ use drk::crypto::{
     nullifier::Nullifier,
     save_params, setup_mint_prover, setup_spend_prover,
 };
-use drk::rpc::adapter::RpcAdapter;
+use drk::rpc::adapters::user_adapter::UserAdapter;
 use drk::rpc::jsonserver;
 use drk::serial::{deserialize, Decodable, Encodable};
 use drk::service::{CashierClient, GatewayClient, GatewaySlabsSubscriber};
@@ -32,7 +32,6 @@ use futures::FutureExt;
 use std::net::SocketAddr;
 use std::path::Path;
 use std::path::PathBuf;
-use std::str::FromStr;
 
 pub struct State {
     // The entire merkle tree state
@@ -325,7 +324,7 @@ async fn start(executor: Arc<Executor<'_>>, config: Arc<&DarkfidConfig>) -> Resu
         Ok::<(), drk::Error>(())
     });
 
-    let adapter = Arc::new(RpcAdapter::new(
+    let adapter = Arc::new(UserAdapter::new(
         wallet.clone(),
         publish_tx_send,
         (deposit_req_send, deposit_rep_recv),

+ 0 - 0
src/rpc/adapters/cashier_adapter.rs


+ 4 - 0
src/rpc/adapters/mod.rs

@@ -0,0 +1,4 @@
+pub mod cashier_adapter;
+pub mod user_adapter;
+
+pub use user_adapter::{UserAdapterPtr, UserAdapter};

+ 3 - 3
src/rpc/adapter.rs → src/rpc/adapters/user_adapter.rs

@@ -10,7 +10,7 @@ use log::*;
 
 use async_std::sync::Arc;
 
-pub type AdapterPtr = Arc<RpcAdapter>;
+pub type UserAdapterPtr = Arc<UserAdapter>;
 pub type DepositChannel = (
     async_channel::Sender<jubjub::SubgroupPoint>,
     async_channel::Receiver<Option<bitcoin::util::address::Address>>,
@@ -20,14 +20,14 @@ pub type WithdrawChannel = (
     async_channel::Receiver<Option<jubjub::SubgroupPoint>>,
 );
 
-pub struct RpcAdapter {
+pub struct UserAdapter {
     pub wallet: Arc<WalletDb>,
     publish_tx_send: async_channel::Sender<TransferParams>,
     deposit_channel: DepositChannel,
     withdraw_channel: WithdrawChannel,
 }
 
-impl RpcAdapter {
+impl UserAdapter {
     pub fn new(
         wallet: Arc<WalletDb>,
         publish_tx_send: async_channel::Sender<TransferParams>,

+ 4 - 4
src/rpc/jsonserver.rs

@@ -1,6 +1,6 @@
 use crate::cli::DarkfidConfig;
 use crate::cli::{TransferParams, WithdrawParams};
-use crate::rpc::adapter::RpcAdapter;
+use crate::rpc::adapters::user_adapter::UserAdapter;
 use crate::{Error, Result};
 
 use async_executor::Executor;
@@ -77,7 +77,7 @@ pub async fn listen(
 pub async fn start(
     executor: Arc<Executor<'_>>,
     config: Arc<&DarkfidConfig>,
-    adapter: Arc<RpcAdapter>,
+    adapter: Arc<UserAdapter>,
 ) -> Result<()> {
     let rpc = RpcInterface::new(adapter)?;
     let rpc_url: std::net::SocketAddr = config.rpc_url.parse()?;
@@ -104,11 +104,11 @@ pub struct RpcInterface {
     pub started: Mutex<bool>,
     stop_send: async_channel::Sender<()>,
     stop_recv: async_channel::Receiver<()>,
-    adapter: Arc<RpcAdapter>,
+    adapter: Arc<UserAdapter>,
 }
 
 impl RpcInterface {
-    pub fn new(adapter: Arc<RpcAdapter>) -> Result<Arc<Self>> {
+    pub fn new(adapter: Arc<UserAdapter>) -> Result<Arc<Self>> {
         let (stop_send, stop_recv) = async_channel::unbounded::<()>();
         Ok(Arc::new(Self {
             started: Mutex::new(false),

+ 1 - 3
src/rpc/mod.rs

@@ -1,6 +1,4 @@
-pub mod adapter;
 pub mod jsonrpc;
 pub mod jsonserver;
-pub mod test;
+pub mod adapters;
 
-pub use adapter::{AdapterPtr, RpcAdapter};

+ 0 - 1
src/rpc/test.rs

@@ -1 +0,0 @@
-