gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-depolymerization] branch master updated (2295a6e -> 3e4647f)


From: gnunet
Subject: [taler-depolymerization] branch master updated (2295a6e -> 3e4647f)
Date: Wed, 02 Mar 2022 21:26:14 +0100

This is an automated email from the git hooks/post-receive script.

antoine pushed a change to branch master
in repository depolymerization.

    from 2295a6e  instrumentation: ethereum success on ropsten network
     new dda3810  Fix gateway and clippy fix
     new 3e4647f  Improve initwallet

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 btc-wire/src/lib.rs         |  4 ++--
 btc-wire/src/main.rs        | 14 --------------
 eth-wire/src/lib.rs         |  4 ++--
 eth-wire/src/main.rs        | 19 +++++++++----------
 instrumentation/src/btc.rs  |  4 ++--
 instrumentation/src/eth.rs  |  4 ++--
 instrumentation/src/main.rs | 37 +++++++++++++++----------------------
 wire-gateway/src/main.rs    |  8 ++++----
 8 files changed, 36 insertions(+), 58 deletions(-)

diff --git a/btc-wire/src/lib.rs b/btc-wire/src/lib.rs
index b7be536..78f0c51 100644
--- a/btc-wire/src/lib.rs
+++ b/btc-wire/src/lib.rs
@@ -140,12 +140,12 @@ impl Rpc {
     }
 }
 
-const DEFAULT_BOUNCE_FEE: &'static str = "BTC:0.00001";
+const DEFAULT_BOUNCE_FEE: &str = "BTC:0.00001";
 const DEFAULT_CONFIRMATION: u16 = 6;
 
 fn config_bounce_fee(config: &BtcConfig) -> Amount {
     let config = config.bounce_fee.as_deref().unwrap_or(DEFAULT_BOUNCE_FEE);
-    TalerAmount::from_str(&config)
+    TalerAmount::from_str(config)
         .ok()
         .and_then(|a| taler_to_btc(&a).ok())
         .expect("config value BOUNCE_FEE is no a valid bitcoin amount")
diff --git a/btc-wire/src/main.rs b/btc-wire/src/main.rs
index 5f748fb..742f9a3 100644
--- a/btc-wire/src/main.rs
+++ b/btc-wire/src/main.rs
@@ -102,20 +102,6 @@ fn init(config: Option<PathBuf>, init: Init) {
             println!("Database initialised");
         }
         Init::Initwallet => {
-            // Skip past blocks
-            let info = rpc
-                .get_blockchain_info()
-                .expect("Failed to get blockchain info");
-            let nb_row = db
-                .execute(
-                    "INSERT INTO state (name, value) VALUES ('last_hash', $1) 
ON CONFLICT (name) DO NOTHING",
-                    &[&info.best_block_hash.as_ref()],
-                )
-                .expect("Failed to update database state");
-            if nb_row > 0 {
-                println!("Skip previous block until now");
-            }
-
             // Create wallet
             let passwd = password();
             let created = match rpc.create_wallet(WIRE_WALLET_NAME, &passwd) {
diff --git a/eth-wire/src/lib.rs b/eth-wire/src/lib.rs
index 3ee6870..a54f0ca 100644
--- a/eth-wire/src/lib.rs
+++ b/eth-wire/src/lib.rs
@@ -197,7 +197,7 @@ impl SyncState {
 }
 
 const DEFAULT_CONFIRMATION: u16 = 24;
-const DEFAULT_BOUNCE_FEE: &'static str = "ETH:0.00001";
+const DEFAULT_BOUNCE_FEE: &str = "ETH:0.00001";
 pub struct WireState {
     pub confirmation: AtomicU32,
     pub max_confirmations: u32,
@@ -221,7 +221,7 @@ impl WireState {
 
 fn config_bounce_fee(config: &EthConfig) -> U256 {
     let config = config.bounce_fee.as_deref().unwrap_or(DEFAULT_BOUNCE_FEE);
-    Amount::from_str(&config)
+    Amount::from_str(config)
         .ok()
         .and_then(|a| taler_to_eth(&a).ok())
         .expect("config value BOUNCE_FEE is no a valid ethereum amount")
diff --git a/eth-wire/src/main.rs b/eth-wire/src/main.rs
index 91dc4d7..c78a17d 100644
--- a/eth-wire/src/main.rs
+++ b/eth-wire/src/main.rs
@@ -113,16 +113,6 @@ fn init(config: Option<PathBuf>, init: Init) {
                 tip_height: block.number.unwrap(),
                 conf_height: block.number.unwrap(),
             };
-            let nb_row = db
-                      .execute(
-                          "INSERT INTO state (name, value) VALUES ('sync', $1) 
ON CONFLICT (name) DO NOTHING",
-                          &[&state.to_bytes().as_ref()],
-                      )
-                      .expect("Failed to update database state");
-            if nb_row > 0 {
-                println!("Skipped {} previous block", state.conf_height);
-            }
-
             let prev_addr = db
                 .query_opt("SELECT value FROM state WHERE name = 'addr'", &[])
                 .expect("Failed to query database state");
@@ -137,6 +127,15 @@ fn init(config: Option<PathBuf>, init: Init) {
                     &[&new.as_bytes()],
                 )
                 .expect("Failed to update database state");
+                let nb_row = db
+                    .execute(
+                        "UPDATE state SET value=$1 WHERE name='sync'",
+                        &[&state.to_bytes().as_ref()],
+                    )
+                    .expect("Failed to update database state");
+                if nb_row > 0 {
+                    println!("Skipped {} previous block", state.conf_height);
+                }
                 (new, true)
             };
 
diff --git a/instrumentation/src/btc.rs b/instrumentation/src/btc.rs
index b019279..396c700 100644
--- a/instrumentation/src/btc.rs
+++ b/instrumentation/src/btc.rs
@@ -39,8 +39,8 @@ fn wait_for_pending(since: &mut BlockHash, client_rpc: &mut 
Rpc, wire_rpc: &mut
     print_now("Wait for pending transactions mining:");
     'l: loop {
         std::thread::sleep(Duration::from_secs(1)); // Wait for btc-wire to act
-        let sync = client_rpc.list_since_block(Some(&since), 1).unwrap();
-        let sync2 = wire_rpc.list_since_block(Some(&since), 1).unwrap();
+        let sync = client_rpc.list_since_block(Some(since), 1).unwrap();
+        let sync2 = wire_rpc.list_since_block(Some(since), 1).unwrap();
         *since = sync.lastblock;
         for tx in sync
             .transactions
diff --git a/instrumentation/src/eth.rs b/instrumentation/src/eth.rs
index 5a96294..3eaba6b 100644
--- a/instrumentation/src/eth.rs
+++ b/instrumentation/src/eth.rs
@@ -50,8 +50,8 @@ pub fn eth_test(config: Option<&Path>, base_url: &str) {
         .unwrap()
         .into_iter()
         .skip(1) // Skip etherbase if dev network
-        .filter(|addr| addr != &state.address) // Skip wire
-        .next();
+        .find(|addr| addr != &state.address); // Skip wire
+        
     let client_addr = match client {
         Some(addr) => addr,
         None => rpc.new_account("password").unwrap(),
diff --git a/instrumentation/src/main.rs b/instrumentation/src/main.rs
index e9137ea..e6d45b2 100644
--- a/instrumentation/src/main.rs
+++ b/instrumentation/src/main.rs
@@ -22,7 +22,8 @@ use common::{
     api_common::{Amount, Base32},
     api_wire::{IncomingBankTransaction, IncomingHistory, OutgoingHistory, 
TransferRequest},
     config::{Config, GatewayConfig},
-    url::Url, rand_slice,
+    rand_slice,
+    url::Url,
 };
 use eth::eth_test;
 
@@ -42,20 +43,16 @@ fn check_incoming(base_url: &str, reserve_pub_key: &[u8; 
32], taler_amount: &Amo
         .unwrap()
         .into_json()
         .unwrap();
-    assert!(history
-        .incoming_transactions
-        .iter()
-        .find(|h| {
-            matches!(
-                h,
-                IncomingBankTransaction::IncomingReserveTransaction {
-                    reserve_pub,
-                    amount,
-                    ..
-                } if reserve_pub == &Base32::from(*reserve_pub_key) && amount 
== taler_amount
-            )
-        })
-        .is_some());
+    assert!(history.incoming_transactions.iter().any(|h| {
+        matches!(
+            h,
+            IncomingBankTransaction::IncomingReserveTransaction {
+                reserve_pub,
+                amount,
+                ..
+            } if reserve_pub == &Base32::from(*reserve_pub_key) && amount == 
taler_amount
+        )
+    }));
 }
 
 fn transfer(base_url: &str, wtid: &[u8; 32], url: &Url, credit_account: Url, 
amount: &Amount) {
@@ -79,13 +76,9 @@ fn check_outgoing(base_url: &str, wtid: &[u8; 32], url: 
&Url, amount: &Amount) {
         .unwrap()
         .into_json()
         .unwrap();
-    assert!(history
-        .outgoing_transactions
-        .iter()
-        .find(|h| {
-            h.wtid == Base32::from(*wtid) && &h.exchange_base_url == url && 
&h.amount == amount
-        })
-        .is_some());
+    assert!(history.outgoing_transactions.iter().any(|h| {
+        h.wtid == Base32::from(*wtid) && &h.exchange_base_url == url && 
&h.amount == amount
+    }));
 }
 
 /// Depolymerizer instrumentation test
diff --git a/wire-gateway/src/main.rs b/wire-gateway/src/main.rs
index 6996ddc..fbba4fb 100644
--- a/wire-gateway/src/main.rs
+++ b/wire-gateway/src/main.rs
@@ -23,7 +23,7 @@ use common::{
     config::{Config, GatewayConfig},
     error_codes::ErrorCode,
     log::log::{error, info, log, Level},
-    postgres::{fallible_iterator::FallibleIterator, Client},
+    postgres::fallible_iterator::FallibleIterator,
     sql::{sql_amount, sql_array, sql_safe_u64, sql_url},
     url::Url,
 };
@@ -98,13 +98,13 @@ struct Args {
 async fn main() {
     common::log::init();
     let args = Args::parse();
-    let conf = GatewayConfig::load_taler_config(args.config.as_deref(),None);
+    let conf = GatewayConfig::load_taler_config(args.config.as_deref(), None);
 
     #[cfg(feature = "test")]
     common::log::log::warn!("Running with test admin endpoint unsuitable for 
production");
 
     // Parse postgres url
-    let config = tokio_postgres::Config::from_str(&conf.core.db_url).unwrap();
+    let config = &conf.core.db_config;
     // TODO find a way to clean this ugly mess
     let mut cfg = deadpool_postgres::Config::new();
     cfg.user = config.get_user().map(|it| it.to_string());
@@ -480,7 +480,7 @@ async fn router(
 /// Listen to backend status change
 fn status_watcher(state: &'static ServerState) {
     fn inner(state: &'static ServerState) -> Result<(), Box<dyn 
std::error::Error>> {
-        let mut db = Client::connect(&state.config.core.db_url, NoTls)?;
+        let mut db = state.config.core.db_config.connect(NoTls)?;
         // Register as listener
         db.batch_execute("LISTEN status")?;
         loop {

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]