mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
chainntnfs/height_hint_cache: prevent db transactions with no updates
In this commit, we modify our height hint cache to no longer start a database transaction if no outpoints/txids are provided to update the height hints for.
This commit is contained in:
parent
39d86d5731
commit
f4cf1073d4
1 changed files with 16 additions and 0 deletions
|
@ -127,6 +127,10 @@ func (c *HeightHintCache) CommitSpendHint(height uint32, ops ...wire.OutPoint) e
|
|||
return nil
|
||||
}
|
||||
|
||||
if len(ops) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Log.Tracef("Updating spend hint to height %d for %v", height, ops)
|
||||
|
||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||
|
@ -197,6 +201,10 @@ func (c *HeightHintCache) PurgeSpendHint(ops ...wire.OutPoint) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if len(ops) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Log.Tracef("Removing spend hints for %v", ops)
|
||||
|
||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||
|
@ -228,6 +236,10 @@ func (c *HeightHintCache) CommitConfirmHint(height uint32, txids ...chainhash.Ha
|
|||
return nil
|
||||
}
|
||||
|
||||
if len(txids) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Log.Tracef("Updating confirm hints to height %d for %v", height, txids)
|
||||
|
||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||
|
@ -299,6 +311,10 @@ func (c *HeightHintCache) PurgeConfirmHint(txids ...chainhash.Hash) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if len(txids) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Log.Tracef("Removing confirm hints for %v", txids)
|
||||
|
||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue