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
@ -127,6 +127,10 @@ func (c *HeightHintCache) CommitSpendHint(height uint32, ops ...wire.OutPoint) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(ops) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
Log.Tracef("Updating spend hint to height %d for %v", height, ops)
|
Log.Tracef("Updating spend hint to height %d for %v", height, ops)
|
||||||
|
|
||||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||||
@ -197,6 +201,10 @@ func (c *HeightHintCache) PurgeSpendHint(ops ...wire.OutPoint) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(ops) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
Log.Tracef("Removing spend hints for %v", ops)
|
Log.Tracef("Removing spend hints for %v", ops)
|
||||||
|
|
||||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||||
@ -228,6 +236,10 @@ func (c *HeightHintCache) CommitConfirmHint(height uint32, txids ...chainhash.Ha
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(txids) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
Log.Tracef("Updating confirm hints to height %d for %v", height, txids)
|
Log.Tracef("Updating confirm hints to height %d for %v", height, txids)
|
||||||
|
|
||||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||||
@ -299,6 +311,10 @@ func (c *HeightHintCache) PurgeConfirmHint(txids ...chainhash.Hash) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(txids) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
Log.Tracef("Removing confirm hints for %v", txids)
|
Log.Tracef("Removing confirm hints for %v", txids)
|
||||||
|
|
||||||
return c.db.Batch(func(tx *bolt.Tx) error {
|
return c.db.Batch(func(tx *bolt.Tx) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user