]> Untitled Git - bdk/commitdiff
avoid a max() call by checking minus or equal
authorRiccardo Casatta <riccardo@casatta.it>
Tue, 17 Nov 2020 14:19:09 +0000 (15:19 +0100)
committerRiccardo Casatta <riccardo@casatta.it>
Tue, 17 Nov 2020 14:20:33 +0000 (15:20 +0100)
src/blockchain/utils.rs

index 73db08ced13798210c1910d17e2bb3a2fb530213..79c9c9f09e59bb512fafb64236c02e3d5626c586 100644 (file)
@@ -111,11 +111,10 @@ pub trait ElectrumLikeSync {
                     // el.height = -1 means unconfirmed with unconfirmed parents
                     // el.height =  0 means unconfirmed with confirmed parents
                     // but we threat those tx the same
-                    let height = el.height.max(0);
-                    if height == 0 {
+                    if el.height <= 0 {
                         txid_height.insert(el.tx_hash, None);
                     } else {
-                        txid_height.insert(el.tx_hash, Some(height as u32));
+                        txid_height.insert(el.tx_hash, Some(el.height as u32));
                     }
                     history_txs_id.insert(el.tx_hash);
                 }