Use utility methods to construct `HashMap`s and `HashSet`s
[rust-lightning] / lightning / src / ln / outbound_payment.rs
index db8b43e3f67778239b3d98d437122565d7ffa7ec..c260bac856a72635e5661f3a5dd33d870460db50 100644 (file)
@@ -171,7 +171,7 @@ impl PendingOutboundPayment {
        }
 
        fn mark_fulfilled(&mut self) {
-               let mut session_privs = HashSet::new();
+               let mut session_privs = new_hash_set();
                core::mem::swap(&mut session_privs, match self {
                        PendingOutboundPayment::Legacy { session_privs } |
                                PendingOutboundPayment::Retryable { session_privs, .. } |
@@ -186,7 +186,7 @@ impl PendingOutboundPayment {
 
        fn mark_abandoned(&mut self, reason: PaymentFailureReason) {
                if let PendingOutboundPayment::Retryable { session_privs, payment_hash, .. } = self {
-                       let mut our_session_privs = HashSet::new();
+                       let mut our_session_privs = new_hash_set();
                        core::mem::swap(&mut our_session_privs, session_privs);
                        *self = PendingOutboundPayment::Abandoned {
                                session_privs: our_session_privs,
@@ -195,7 +195,7 @@ impl PendingOutboundPayment {
                        };
                } else if let PendingOutboundPayment::InvoiceReceived { payment_hash, .. } = self {
                        *self = PendingOutboundPayment::Abandoned {
-                               session_privs: HashSet::new(),
+                               session_privs: new_hash_set(),
                                payment_hash: *payment_hash,
                                reason: Some(reason)
                        };
@@ -675,7 +675,7 @@ pub(super) struct OutboundPayments {
 impl OutboundPayments {
        pub(super) fn new() -> Self {
                Self {
-                       pending_outbound_payments: Mutex::new(HashMap::new()),
+                       pending_outbound_payments: Mutex::new(new_hash_map()),
                        retry_lock: Mutex::new(()),
                }
        }
@@ -1268,7 +1268,7 @@ impl OutboundPayments {
                        retry_strategy,
                        attempts: PaymentAttempts::new(),
                        payment_params,
-                       session_privs: HashSet::new(),
+                       session_privs: new_hash_set(),
                        pending_amt_msat: 0,
                        pending_fee_msat: Some(0),
                        payment_hash,