channeldb: fix channeldb.InvoiceHTLC deep copy
This commit fixes deep copy of chaneldb.InvoiceHTLC, where previously the map holding the custom record set wasn't properly copied.
This commit is contained in:
1 parent
658803f51c
commit
ec6c0689ef
1 file changed
+14
-1
+14
-1
@@ -1327,6 +1327,19 @@ func copySlice(src []byte) []byte {
|
|||||||
return dest
|
return dest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copyInvoiceHTLC makes a deep copy of the supplied invoice HTLC.
|
||||||
|
func copyInvoiceHTLC(src *InvoiceHTLC) *InvoiceHTLC {
|
||||||
|
result := *src
|
||||||
|
|
||||||
|
// Make a copy of the CustomSet map.
|
||||||
|
result.CustomRecords = make(record.CustomSet)
|
||||||
|
for k, v := range src.CustomRecords {
|
||||||
|
result.CustomRecords[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
return &result
|
||||||
|
}
|
||||||
|
|
||||||
// copyInvoice makes a deep copy of the supplied invoice.
|
// copyInvoice makes a deep copy of the supplied invoice.
|
||||||
func copyInvoice(src *Invoice) *Invoice {
|
func copyInvoice(src *Invoice) *Invoice {
|
||||||
dest := Invoice{
|
dest := Invoice{
|
||||||
@@ -1347,7 +1360,7 @@ func copyInvoice(src *Invoice) *Invoice {
|
|||||||
dest.Terms.Features = src.Terms.Features.Clone()
|
dest.Terms.Features = src.Terms.Features.Clone()
|
||||||
|
|
||||||
for k, v := range src.Htlcs {
|
for k, v := range src.Htlcs {
|
||||||
dest.Htlcs[k] = v
|
dest.Htlcs[k] = copyInvoiceHTLC(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &dest
|
return &dest
|
||||||
|
|||||||
Reference in new issue
Block a user