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

faucetd: genesis timestamp hardcoded and retrieved based on network

aggstam 4 лет назад
Родитель
Сommit
aa659f7318
1 измененных файлов с 5 добавлено и 11 удалено
  1. 5 11
      bin/faucetd/src/main.rs

+ 5 - 11
bin/faucetd/src/main.rs

@@ -20,8 +20,8 @@ use darkfi::{
     consensus::{
         proto::{ProtocolSync, ProtocolTx},
         task::block_sync_task,
-        Timestamp, ValidatorState, ValidatorStatePtr, MAINNET_GENESIS_HASH_BYTES,
-        TESTNET_GENESIS_HASH_BYTES,
+        ValidatorState, ValidatorStatePtr, MAINNET_GENESIS_HASH_BYTES, MAINNET_GENESIS_TIMESTAMP,
+        TESTNET_GENESIS_HASH_BYTES, TESTNET_GENESIS_TIMESTAMP,
     },
     crypto::{address::Address, keypair::PublicKey, token_list::DrkTokenList},
     net,
@@ -119,10 +119,6 @@ struct Args {
     #[structopt(short, parse(from_occurrences))]
     /// Increase verbosity (-vvv supported)
     verbose: u8,
-
-    #[structopt(short)]
-    /// Genesis time
-    genesis_time: i64,
 }
 
 pub struct Faucetd {
@@ -319,11 +315,9 @@ async fn realmain(args: Args, ex: Arc<Executor<'_>>) -> Result<()> {
     let sled_db = sled::open(&db_path)?;
 
     // Initialize validator state
-    // TODO: genesis_ts should be some hardcoded constant
-    let genesis_ts = Timestamp(args.genesis_time);
-    let genesis_data = match args.chain.as_str() {
-        "mainnet" => *MAINNET_GENESIS_HASH_BYTES,
-        "testnet" => *TESTNET_GENESIS_HASH_BYTES,
+    let (genesis_ts, genesis_data) = match args.chain.as_str() {
+        "mainnet" => (*MAINNET_GENESIS_TIMESTAMP, *MAINNET_GENESIS_HASH_BYTES),
+        "testnet" => (*TESTNET_GENESIS_TIMESTAMP, *TESTNET_GENESIS_HASH_BYTES),
         x => {
             error!("Unsupported chain `{}`", x);
             return Err(Error::UnsupportedChain)