mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 01:18:17 +02:00
routing/localchans: fix nested db tx
This commit fixes a bug where a db tx is opened within another db tx.
This commit is contained in:
@@ -148,6 +148,8 @@ you.
|
|||||||
* [Fixed context leak in integration tests, and properly handled context
|
* [Fixed context leak in integration tests, and properly handled context
|
||||||
timeout](https://github.com/lightningnetwork/lnd/pull/5646).
|
timeout](https://github.com/lightningnetwork/lnd/pull/5646).
|
||||||
|
|
||||||
|
* [Removed nested db tx](https://github.com/lightningnetwork/lnd/pull/5643)
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
* [Ensure single writer for legacy
|
* [Ensure single writer for legacy
|
||||||
|
@@ -81,7 +81,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply the new policy to the edge.
|
// Apply the new policy to the edge.
|
||||||
err := r.updateEdge(info.ChannelPoint, edge, newSchema)
|
err := r.updateEdge(tx, info.ChannelPoint, edge, newSchema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Cannot update policy for %v: %v\n",
|
log.Warnf("Cannot update policy for %v: %v\n",
|
||||||
info.ChannelPoint, err,
|
info.ChannelPoint, err,
|
||||||
@@ -127,7 +127,7 @@ func (r *Manager) UpdatePolicy(newSchema routing.ChannelPolicy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updateEdge updates the given edge with the new schema.
|
// updateEdge updates the given edge with the new schema.
|
||||||
func (r *Manager) updateEdge(chanPoint wire.OutPoint,
|
func (r *Manager) updateEdge(tx kvdb.RTx, chanPoint wire.OutPoint,
|
||||||
edge *channeldb.ChannelEdgePolicy,
|
edge *channeldb.ChannelEdgePolicy,
|
||||||
newSchema routing.ChannelPolicy) error {
|
newSchema routing.ChannelPolicy) error {
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
|
|||||||
edge.TimeLockDelta = uint16(newSchema.TimeLockDelta)
|
edge.TimeLockDelta = uint16(newSchema.TimeLockDelta)
|
||||||
|
|
||||||
// Retrieve negotiated channel htlc amt limits.
|
// Retrieve negotiated channel htlc amt limits.
|
||||||
amtMin, amtMax, err := r.getHtlcAmtLimits(chanPoint)
|
amtMin, amtMax, err := r.getHtlcAmtLimits(tx, chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -198,10 +198,10 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
|
|||||||
|
|
||||||
// getHtlcAmtLimits retrieves the negotiated channel min and max htlc amount
|
// getHtlcAmtLimits retrieves the negotiated channel min and max htlc amount
|
||||||
// constraints.
|
// constraints.
|
||||||
func (r *Manager) getHtlcAmtLimits(chanPoint wire.OutPoint) (
|
func (r *Manager) getHtlcAmtLimits(tx kvdb.RTx, chanPoint wire.OutPoint) (
|
||||||
lnwire.MilliSatoshi, lnwire.MilliSatoshi, error) {
|
lnwire.MilliSatoshi, lnwire.MilliSatoshi, error) {
|
||||||
|
|
||||||
ch, err := r.FetchChannel(nil, chanPoint)
|
ch, err := r.FetchChannel(tx, chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user