ソースを参照

darkfid: Pass cashier and faucet addresses as args.

parazyd 4 年 前
コミット
f0d2ff3d48
1 ファイル変更39 行追加4 行削除
  1. 39 4
      bin/darkfid2/src/main.rs

+ 39 - 4
bin/darkfid2/src/main.rs

@@ -1,4 +1,4 @@
-use std::net::SocketAddr;
+use std::{net::SocketAddr, str::FromStr};
 
 
 use async_executor::Executor;
 use async_executor::Executor;
 use async_std::sync::{Arc, Mutex};
 use async_std::sync::{Arc, Mutex};
@@ -24,7 +24,11 @@ use darkfi::{
         util::Timestamp,
         util::Timestamp,
         ValidatorState, MAINNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_HASH_BYTES,
         ValidatorState, MAINNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_HASH_BYTES,
     },
     },
-    crypto::token_list::{DrkTokenList, TokenList},
+    crypto::{
+        address::Address,
+        keypair::PublicKey,
+        token_list::{DrkTokenList, TokenList},
+    },
     net,
     net,
     net::P2pPtr,
     net::P2pPtr,
     node::Client,
     node::Client,
@@ -123,6 +127,14 @@ struct Args {
     /// Connect to seed for the syncing protocol (repeatable flag)
     /// Connect to seed for the syncing protocol (repeatable flag)
     sync_seed: Vec<SocketAddr>,
     sync_seed: Vec<SocketAddr>,
 
 
+    #[structopt(long)]
+    /// Whitelisted cashier address (repeatable flag)
+    cashier_pub: Vec<String>,
+
+    #[structopt(long)]
+    /// Whitelisted fauced address (repeatable flag)
+    faucet_pub: Vec<String>,
+
     #[structopt(short, parse(from_occurrences))]
     #[structopt(short, parse(from_occurrences))]
     /// Increase verbosity (-vvv supported)
     /// Increase verbosity (-vvv supported)
     verbose: u8,
     verbose: u8,
@@ -239,9 +251,32 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
     // Initialize Client
     // Initialize Client
     let client = Arc::new(Client::new(wallet).await?);
     let client = Arc::new(Client::new(wallet).await?);
 
 
+    // Parse cashier addresses
+    let mut cashier_pubkeys = vec![];
+    for i in args.cashier_pub {
+        let addr = Address::from_str(&i)?;
+        let pk = PublicKey::try_from(addr)?;
+        cashier_pubkeys.push(pk);
+    }
+
+    // Parse fauced addresses
+    let mut faucet_pubkeys = vec![];
+    for i in args.faucet_pub {
+        let addr = Address::from_str(&i)?;
+        let pk = PublicKey::try_from(addr)?;
+        faucet_pubkeys.push(pk);
+    }
+
     // Initialize validator state
     // Initialize validator state
-    let state =
-        ValidatorState::new(&sled_db, genesis_ts, genesis_data, client, vec![], vec![]).await?;
+    let state = ValidatorState::new(
+        &sled_db,
+        genesis_ts,
+        genesis_data,
+        client,
+        cashier_pubkeys,
+        faucet_pubkeys,
+    )
+    .await?;
 
 
     let sync_p2p = {
     let sync_p2p = {
         info!("Registering block sync P2P protocols...");
         info!("Registering block sync P2P protocols...");