mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-07 03:06:01 +02:00
channeldb: convert concurrent channel state machine calls to use Batch
This commit is contained in:
@@ -1027,7 +1027,7 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *ChannelCommitment) error {
|
|||||||
return ErrNoRestoredChannelMutation
|
return ErrNoRestoredChannelMutation
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.Db.Update(func(tx *bbolt.Tx) error {
|
err := c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
chanBucket, err := fetchChanBucket(
|
chanBucket, err := fetchChanBucket(
|
||||||
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
|
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
|
||||||
)
|
)
|
||||||
@@ -1465,7 +1465,7 @@ func (c *OpenChannel) AppendRemoteCommitChain(diff *CommitDiff) error {
|
|||||||
return ErrNoRestoredChannelMutation
|
return ErrNoRestoredChannelMutation
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.Db.Update(func(tx *bbolt.Tx) error {
|
return c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
// First, we'll grab the writable bucket where this channel's
|
// First, we'll grab the writable bucket where this channel's
|
||||||
// data resides.
|
// data resides.
|
||||||
chanBucket, err := fetchChanBucket(
|
chanBucket, err := fetchChanBucket(
|
||||||
@@ -1608,7 +1608,9 @@ func (c *OpenChannel) AdvanceCommitChainTail(fwdPkg *FwdPkg) error {
|
|||||||
|
|
||||||
var newRemoteCommit *ChannelCommitment
|
var newRemoteCommit *ChannelCommitment
|
||||||
|
|
||||||
err := c.Db.Update(func(tx *bbolt.Tx) error {
|
err := c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
|
newRemoteCommit = nil
|
||||||
|
|
||||||
chanBucket, err := fetchChanBucket(
|
chanBucket, err := fetchChanBucket(
|
||||||
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
|
tx, c.IdentityPub, &c.FundingOutpoint, c.ChainHash,
|
||||||
)
|
)
|
||||||
@@ -1746,7 +1748,7 @@ func (c *OpenChannel) AckAddHtlcs(addRefs ...AddRef) error {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
return c.Db.Update(func(tx *bbolt.Tx) error {
|
return c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
return c.Packager.AckAddHtlcs(tx, addRefs...)
|
return c.Packager.AckAddHtlcs(tx, addRefs...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1759,7 +1761,7 @@ func (c *OpenChannel) AckSettleFails(settleFailRefs ...SettleFailRef) error {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
return c.Db.Update(func(tx *bbolt.Tx) error {
|
return c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
return c.Packager.AckSettleFails(tx, settleFailRefs...)
|
return c.Packager.AckSettleFails(tx, settleFailRefs...)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1770,7 +1772,7 @@ func (c *OpenChannel) SetFwdFilter(height uint64, fwdFilter *PkgFilter) error {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
return c.Db.Update(func(tx *bbolt.Tx) error {
|
return c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
return c.Packager.SetFwdFilter(tx, height, fwdFilter)
|
return c.Packager.SetFwdFilter(tx, height, fwdFilter)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1783,14 +1785,15 @@ func (c *OpenChannel) RemoveFwdPkg(height uint64) error {
|
|||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
return c.Db.Update(func(tx *bbolt.Tx) error {
|
return c.Db.Batch(func(tx *bbolt.Tx) error {
|
||||||
return c.Packager.RemovePkg(tx, height)
|
return c.Packager.RemovePkg(tx, height)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// RevocationLogTail returns the "tail", or the end of the current revocation
|
// RevocationLogTail returns the "tail", or the end of the current revocation
|
||||||
// log. This entry represents the last previous state for the remote node's
|
// log. This entry represents the last previous state for the remote node's
|
||||||
// commitment chain. The ChannelDelta returned by this method will always lag one state behind the most current (unrevoked) state of the remote node's
|
// commitment chain. The ChannelDelta returned by this method will always lag
|
||||||
|
// one state behind the most current (unrevoked) state of the remote node's
|
||||||
// commitment chain.
|
// commitment chain.
|
||||||
func (c *OpenChannel) RevocationLogTail() (*ChannelCommitment, error) {
|
func (c *OpenChannel) RevocationLogTail() (*ChannelCommitment, error) {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
|
Reference in New Issue
Block a user