Revert "chainntnfs/height_hint_cache: add disable flag to hint cache"
This reverts commit 7df9ae026665de75175853e486143ab80122ce9d.
This commit is contained in:
parent
08c2ee05f6
commit
716c20b18d
@ -86,7 +86,6 @@ type ConfirmHintCache interface {
|
|||||||
// will be stored.
|
// will be stored.
|
||||||
type HeightHintCache struct {
|
type HeightHintCache struct {
|
||||||
db *channeldb.DB
|
db *channeldb.DB
|
||||||
disabled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile-time checks to ensure HeightHintCache satisfies the SpendHintCache
|
// Compile-time checks to ensure HeightHintCache satisfies the SpendHintCache
|
||||||
@ -95,11 +94,8 @@ var _ SpendHintCache = (*HeightHintCache)(nil)
|
|||||||
var _ ConfirmHintCache = (*HeightHintCache)(nil)
|
var _ ConfirmHintCache = (*HeightHintCache)(nil)
|
||||||
|
|
||||||
// NewHeightHintCache returns a new height hint cache backed by a database.
|
// NewHeightHintCache returns a new height hint cache backed by a database.
|
||||||
func NewHeightHintCache(db *channeldb.DB, disable bool) (*HeightHintCache, error) {
|
func NewHeightHintCache(db *channeldb.DB) (*HeightHintCache, error) {
|
||||||
cache := &HeightHintCache{
|
cache := &HeightHintCache{db}
|
||||||
db: db,
|
|
||||||
disabled: disable,
|
|
||||||
}
|
|
||||||
if err := cache.initBuckets(); err != nil {
|
if err := cache.initBuckets(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -123,10 +119,6 @@ func (c *HeightHintCache) initBuckets() error {
|
|||||||
|
|
||||||
// CommitSpendHint commits a spend hint for the outpoints to the cache.
|
// CommitSpendHint commits a spend hint for the outpoints to the cache.
|
||||||
func (c *HeightHintCache) CommitSpendHint(height uint32, ops ...wire.OutPoint) error {
|
func (c *HeightHintCache) CommitSpendHint(height uint32, ops ...wire.OutPoint) error {
|
||||||
if c.disabled {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ops) == 0 {
|
if len(ops) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -165,10 +157,6 @@ func (c *HeightHintCache) CommitSpendHint(height uint32, ops ...wire.OutPoint) e
|
|||||||
// ErrSpendHintNotFound is returned if a spend hint does not exist within the
|
// ErrSpendHintNotFound is returned if a spend hint does not exist within the
|
||||||
// cache for the outpoint.
|
// cache for the outpoint.
|
||||||
func (c *HeightHintCache) QuerySpendHint(op wire.OutPoint) (uint32, error) {
|
func (c *HeightHintCache) QuerySpendHint(op wire.OutPoint) (uint32, error) {
|
||||||
if c.disabled {
|
|
||||||
return 0, ErrSpendHintNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
var hint uint32
|
var hint uint32
|
||||||
err := c.db.View(func(tx *bolt.Tx) error {
|
err := c.db.View(func(tx *bolt.Tx) error {
|
||||||
spendHints := tx.Bucket(spendHintBucket)
|
spendHints := tx.Bucket(spendHintBucket)
|
||||||
@ -197,10 +185,6 @@ func (c *HeightHintCache) QuerySpendHint(op wire.OutPoint) (uint32, error) {
|
|||||||
|
|
||||||
// PurgeSpendHint removes the spend hint for the outpoints from the cache.
|
// PurgeSpendHint removes the spend hint for the outpoints from the cache.
|
||||||
func (c *HeightHintCache) PurgeSpendHint(ops ...wire.OutPoint) error {
|
func (c *HeightHintCache) PurgeSpendHint(ops ...wire.OutPoint) error {
|
||||||
if c.disabled {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ops) == 0 {
|
if len(ops) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -232,10 +216,6 @@ func (c *HeightHintCache) PurgeSpendHint(ops ...wire.OutPoint) error {
|
|||||||
|
|
||||||
// CommitConfirmHint commits a confirm hint for the transactions to the cache.
|
// CommitConfirmHint commits a confirm hint for the transactions to the cache.
|
||||||
func (c *HeightHintCache) CommitConfirmHint(height uint32, txids ...chainhash.Hash) error {
|
func (c *HeightHintCache) CommitConfirmHint(height uint32, txids ...chainhash.Hash) error {
|
||||||
if c.disabled {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(txids) == 0 {
|
if len(txids) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -274,10 +254,6 @@ func (c *HeightHintCache) CommitConfirmHint(height uint32, txids ...chainhash.Ha
|
|||||||
// ErrConfirmHintNotFound is returned if a confirm hint does not exist within
|
// ErrConfirmHintNotFound is returned if a confirm hint does not exist within
|
||||||
// the cache for the transaction hash.
|
// the cache for the transaction hash.
|
||||||
func (c *HeightHintCache) QueryConfirmHint(txid chainhash.Hash) (uint32, error) {
|
func (c *HeightHintCache) QueryConfirmHint(txid chainhash.Hash) (uint32, error) {
|
||||||
if c.disabled {
|
|
||||||
return 0, ErrConfirmHintNotFound
|
|
||||||
}
|
|
||||||
|
|
||||||
var hint uint32
|
var hint uint32
|
||||||
err := c.db.View(func(tx *bolt.Tx) error {
|
err := c.db.View(func(tx *bolt.Tx) error {
|
||||||
confirmHints := tx.Bucket(confirmHintBucket)
|
confirmHints := tx.Bucket(confirmHintBucket)
|
||||||
@ -307,10 +283,6 @@ func (c *HeightHintCache) QueryConfirmHint(txid chainhash.Hash) (uint32, error)
|
|||||||
// PurgeConfirmHint removes the confirm hint for the transactions from the
|
// PurgeConfirmHint removes the confirm hint for the transactions from the
|
||||||
// cache.
|
// cache.
|
||||||
func (c *HeightHintCache) PurgeConfirmHint(txids ...chainhash.Hash) error {
|
func (c *HeightHintCache) PurgeConfirmHint(txids ...chainhash.Hash) error {
|
||||||
if c.disabled {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(txids) == 0 {
|
if len(txids) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user