60
60
// value: time || rawSwapState
61
61
contractKey = []byte ("contract" )
62
62
63
+ // labelKey is the key that stores an optional label for the swap. If
64
+ // a swap was created before we started adding labels, or was created
65
+ // without a label, this key will not be present.
66
+ //
67
+ // path: loopInBucket/loopOutBucket -> swapBucket[hash] -> labelKey
68
+ //
69
+ // value: string label
70
+ labelKey = []byte ("label" )
71
+
63
72
// outgoingChanSetKey is the key that stores a list of channel ids that
64
73
// restrict the loop out swap payment.
65
74
//
@@ -207,6 +216,9 @@ func (s *boltSwapStore) FetchLoopOutSwaps() ([]*LoopOut, error) {
207
216
return err
208
217
}
209
218
219
+ // Get our label for this swap, if it is present.
220
+ contract .Label = getLabel (swapBucket )
221
+
210
222
// Read the list of concatenated outgoing channel ids
211
223
// that form the outgoing set.
212
224
setBytes := swapBucket .Get (outgoingChanSetKey )
@@ -352,6 +364,9 @@ func (s *boltSwapStore) FetchLoopInSwaps() ([]*LoopIn, error) {
352
364
return err
353
365
}
354
366
367
+ // Get our label for this swap, if it is present.
368
+ contract .Label = getLabel (swapBucket )
369
+
355
370
updates , err := deserializeUpdates (swapBucket )
356
371
if err != nil {
357
372
return err
@@ -434,6 +449,10 @@ func (s *boltSwapStore) CreateLoopOut(hash lntypes.Hash,
434
449
return err
435
450
}
436
451
452
+ if err := putLabel (swapBucket , swap .Label ); err != nil {
453
+ return err
454
+ }
455
+
437
456
// Write the outgoing channel set.
438
457
var b bytes.Buffer
439
458
for _ , chanID := range swap .OutgoingChanSet {
@@ -447,6 +466,11 @@ func (s *boltSwapStore) CreateLoopOut(hash lntypes.Hash,
447
466
return err
448
467
}
449
468
469
+ // Write label to disk if we have one.
470
+ if err := putLabel (swapBucket , swap .Label ); err != nil {
471
+ return err
472
+ }
473
+
450
474
// Finally, we'll create an empty updates bucket for this swap
451
475
// to track any future updates to the swap itself.
452
476
_ , err = swapBucket .CreateBucket (updatesBucketKey )
@@ -485,6 +509,11 @@ func (s *boltSwapStore) CreateLoopIn(hash lntypes.Hash,
485
509
return err
486
510
}
487
511
512
+ // Write label to disk if we have one.
513
+ if err := putLabel (swapBucket , swap .Label ); err != nil {
514
+ return err
515
+ }
516
+
488
517
// Finally, we'll create an empty updates bucket for this swap
489
518
// to track any future updates to the swap itself.
490
519
_ , err = swapBucket .CreateBucket (updatesBucketKey )
0 commit comments