Skip to content

Commit 27b9b93

Browse files
committed
f Inline kind
1 parent 765bf8e commit 27b9b93

File tree

4 files changed

+47
-60
lines changed

4 files changed

+47
-60
lines changed

src/event.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,12 @@ where
600600
return;
601601
},
602602
PaymentPurpose::SpontaneousPayment(preimage) => {
603-
let kind = PaymentKind::Spontaneous {
604-
hash: payment_hash,
605-
preimage: Some(preimage),
606-
};
607603
let payment = PaymentDetails {
608604
id: payment_id,
609-
kind,
605+
kind: PaymentKind::Spontaneous {
606+
hash: payment_hash,
607+
preimage: Some(preimage),
608+
},
610609
amount_msat: Some(amount_msat),
611610
direction: PaymentDirection::Inbound,
612611
status: PaymentStatus::Succeeded,

src/payment/bolt11.rs

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,18 @@ impl Bolt11Payment {
102102
let amt_msat = invoice.amount_milli_satoshis().unwrap();
103103
log_info!(self.logger, "Initiated sending {}msat to {}", amt_msat, payee_pubkey);
104104

105-
let kind = PaymentKind::Bolt11 {
106-
hash: payment_hash,
107-
preimage: None,
108-
secret: payment_secret,
109-
};
110-
111105
let payment = PaymentDetails {
112106
id: payment_id,
113-
kind,
107+
kind: PaymentKind::Bolt11 {
108+
hash: payment_hash,
109+
preimage: None,
110+
secret: payment_secret,
111+
},
114112
amount_msat: invoice.amount_milli_satoshis(),
115113
direction: PaymentDirection::Outbound,
116114
status: PaymentStatus::Pending,
117115
};
116+
118117
self.payment_store.insert(payment)?;
119118

120119
Ok(payment_id)
@@ -124,14 +123,13 @@ impl Bolt11Payment {
124123
match e {
125124
RetryableSendFailure::DuplicatePayment => Err(Error::DuplicatePayment),
126125
_ => {
127-
let kind = PaymentKind::Bolt11 {
128-
hash: payment_hash,
129-
preimage: None,
130-
secret: payment_secret,
131-
};
132126
let payment = PaymentDetails {
133127
id: payment_id,
134-
kind,
128+
kind: PaymentKind::Bolt11 {
129+
hash: payment_hash,
130+
preimage: None,
131+
secret: payment_secret,
132+
},
135133
amount_msat: invoice.amount_milli_satoshis(),
136134
direction: PaymentDirection::Outbound,
137135
status: PaymentStatus::Failed,
@@ -215,15 +213,13 @@ impl Bolt11Payment {
215213
payee_pubkey
216214
);
217215

218-
let kind = PaymentKind::Bolt11 {
219-
hash: payment_hash,
220-
preimage: None,
221-
secret: Some(*payment_secret),
222-
};
223-
224216
let payment = PaymentDetails {
225217
id: payment_id,
226-
kind,
218+
kind: PaymentKind::Bolt11 {
219+
hash: payment_hash,
220+
preimage: None,
221+
secret: Some(*payment_secret),
222+
},
227223
amount_msat: Some(amount_msat),
228224
direction: PaymentDirection::Outbound,
229225
status: PaymentStatus::Pending,
@@ -238,15 +234,13 @@ impl Bolt11Payment {
238234
match e {
239235
RetryableSendFailure::DuplicatePayment => Err(Error::DuplicatePayment),
240236
_ => {
241-
let kind = PaymentKind::Bolt11 {
242-
hash: payment_hash,
243-
preimage: None,
244-
secret: Some(*payment_secret),
245-
};
246-
247237
let payment = PaymentDetails {
248238
id: payment_id,
249-
kind,
239+
kind: PaymentKind::Bolt11 {
240+
hash: payment_hash,
241+
preimage: None,
242+
secret: Some(*payment_secret),
243+
},
250244
amount_msat: Some(amount_msat),
251245
direction: PaymentDirection::Outbound,
252246
status: PaymentStatus::Failed,
@@ -303,15 +297,14 @@ impl Bolt11Payment {
303297

304298
let payment_hash = PaymentHash(invoice.payment_hash().to_byte_array());
305299
let id = PaymentId(payment_hash.0);
306-
let kind = PaymentKind::Bolt11 {
307-
hash: payment_hash,
308-
preimage: None,
309-
secret: Some(invoice.payment_secret().clone()),
310-
};
311-
312300
let payment = PaymentDetails {
313301
id,
314-
kind,
302+
kind: PaymentKind::Bolt11 {
303+
hash: payment_hash,
304+
preimage: None,
305+
secret: Some(invoice.payment_secret().clone()),
306+
},
307+
315308
amount_msat,
316309
direction: PaymentDirection::Inbound,
317310
status: PaymentStatus::Pending,
@@ -434,15 +427,14 @@ impl Bolt11Payment {
434427
max_proportional_opening_fee_ppm_msat: lsp_prop_opening_fee,
435428
};
436429
let id = PaymentId(payment_hash.0);
437-
let kind = PaymentKind::Bolt11Jit {
438-
hash: payment_hash,
439-
preimage: None,
440-
secret: Some(invoice.payment_secret().clone()),
441-
lsp_fee_limits,
442-
};
443430
let payment = PaymentDetails {
444431
id,
445-
kind,
432+
kind: PaymentKind::Bolt11Jit {
433+
hash: payment_hash,
434+
preimage: None,
435+
secret: Some(invoice.payment_secret().clone()),
436+
lsp_fee_limits,
437+
},
446438
amount_msat,
447439
direction: PaymentDirection::Inbound,
448440
status: PaymentStatus::Pending,

src/payment/spontaneous.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,12 @@ impl SpontaneousPayment {
7777
Ok(_hash) => {
7878
log_info!(self.logger, "Initiated sending {}msat to {}.", amount_msat, node_id);
7979

80-
let kind = PaymentKind::Spontaneous {
81-
hash: payment_hash,
82-
preimage: Some(payment_preimage),
83-
};
84-
8580
let payment = PaymentDetails {
8681
id: payment_id,
87-
kind,
82+
kind: PaymentKind::Spontaneous {
83+
hash: payment_hash,
84+
preimage: Some(payment_preimage),
85+
},
8886
status: PaymentStatus::Pending,
8987
direction: PaymentDirection::Outbound,
9088
amount_msat: Some(amount_msat),
@@ -99,14 +97,13 @@ impl SpontaneousPayment {
9997
match e {
10098
RetryableSendFailure::DuplicatePayment => Err(Error::DuplicatePayment),
10199
_ => {
102-
let kind = PaymentKind::Spontaneous {
103-
hash: payment_hash,
104-
preimage: Some(payment_preimage),
105-
};
106-
107100
let payment = PaymentDetails {
108101
id: payment_id,
109-
kind,
102+
kind: PaymentKind::Spontaneous {
103+
hash: payment_hash,
104+
preimage: Some(payment_preimage),
105+
},
106+
110107
status: PaymentStatus::Failed,
111108
direction: PaymentDirection::Outbound,
112109
amount_msat: Some(amount_msat),

src/payment/store.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,9 @@ mod tests {
395395
)
396396
.is_err());
397397

398-
let kind = PaymentKind::Bolt11 { hash, preimage: None, secret: None };
399398
let payment = PaymentDetails {
400399
id,
401-
kind,
400+
kind: PaymentKind::Bolt11 { hash, preimage: None, secret: None },
402401
amount_msat: None,
403402
direction: PaymentDirection::Inbound,
404403
status: PaymentStatus::Pending,

0 commit comments

Comments
 (0)