Documentation ¶
Index ¶
- Constants
- func UseLogger(logger slog.Logger)
- type ErrorKind
- type PruneError
- type SpendConsumer
- type SpendJournalNotification
- type SpendJournalPruner
- func (s *SpendJournalPruner) AddConsumer(consumer SpendConsumer)
- func (s *SpendJournalPruner) DependencyExists(blockHash *chainhash.Hash) bool
- func (s *SpendJournalPruner) FetchConsumer(id string) (SpendConsumer, error)
- func (s *SpendJournalPruner) HandleSignals(ctx context.Context)
- func (s *SpendJournalPruner) MaybePruneSpendData(blockHash *chainhash.Hash, done chan bool) error
- func (s *SpendJournalPruner) NotifyConnectedBlock(blockHash *chainhash.Hash)
- func (s *SpendJournalPruner) RemoveSpendConsumerDependency(dbTx database.Tx, blockHash *chainhash.Hash, consumerID string) error
Constants ¶
const ( // ErrNoConsumer indicates a spend journal consumer hash does not exist. ErrNoConsumer = ErrorKind("ErrNoConsumer") // ErrLoadSpendDeps indicates an error loading consumer // spend dependencies. ErrLoadSpendDeps = ErrorKind("ErrLoadSpendDeps") // ErrNeedSpendData indicates an error asserting a spend data dependency. ErrNeedSpendData = ErrorKind("ErrNeedSpendData") // ErrUpdateConsumerDeps indicates an error updating consumer spend // dependencies. ErrUpdateConsumerDeps = ErrorKind("ErrUpdateConsumerDeps") )
These constants are used to identify a specific PruneError.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorKind ¶
type ErrorKind string
ErrorKind identifies a kind of error. It has full support for errors.Is and errors.As, so the caller can directly check against an error kind when determining the reason for an error.
type PruneError ¶
PruneError identifies a spend journal pruner error. It has full support for errors.Is and errors.As, so the caller can ascertain the specific reason for the error by checking the underlying error.
func (PruneError) Error ¶
func (e PruneError) Error() string
Error satisfies the error interface and prints human-readable errors.
func (PruneError) Unwrap ¶
func (e PruneError) Unwrap() error
Unwrap returns the underlying wrapped error.
type SpendConsumer ¶
type SpendConsumer interface { // ID returns the identifier of the consumer. ID() string // NeedSpendData checks whether the associated spend journal entry for the // provided block hash will be needed by the consumer. NeedSpendData(hash *chainhash.Hash) (bool, error) }
SpendConsumer describes the requirements for implementing a spend journal consumer.
All functions MUST be safe for concurrent access.
type SpendJournalNotification ¶
type SpendJournalNotification struct { BlockHash *chainhash.Hash Event spendPrunerEventType Done chan bool }
SpendJournalNotification represents the notification received by the pruner on block connections and disconnections.
type SpendJournalPruner ¶
type SpendJournalPruner struct {
// contains filtered or unexported fields
}
SpendJournalPruner represents a spend journal pruner that ensures spend journal entries needed by consumers are retained until no longer needed.
func NewSpendJournalPruner ¶
func NewSpendJournalPruner(db database.DB, removeSpendEntry func(hash *chainhash.Hash) error) (*SpendJournalPruner, error)
NewSpendJournalPruner initializes a spend journal pruner.
func (*SpendJournalPruner) AddConsumer ¶
func (s *SpendJournalPruner) AddConsumer(consumer SpendConsumer)
AddConsumer adds a spend journal consumer to the pruner.
func (*SpendJournalPruner) DependencyExists ¶
func (s *SpendJournalPruner) DependencyExists(blockHash *chainhash.Hash) bool
DependencyExists determines whether there are spend consumer dependencies for the provided block hash.
func (*SpendJournalPruner) FetchConsumer ¶
func (s *SpendJournalPruner) FetchConsumer(id string) (SpendConsumer, error)
FetchConsumer returns the spend journal consumer associated with the provided id.
func (*SpendJournalPruner) HandleSignals ¶
func (s *SpendJournalPruner) HandleSignals(ctx context.Context)
HandleSignals processes incoming signals to the spend pruner.
func (*SpendJournalPruner) MaybePruneSpendData ¶
func (s *SpendJournalPruner) MaybePruneSpendData(blockHash *chainhash.Hash, done chan bool) error
MaybePruneSpendData firsts adds consumer spend dependencies for the provided blockhash if any. If there are no dependencies the spend journal entry associated with the provided block hash is pruned.
func (*SpendJournalPruner) NotifyConnectedBlock ¶
func (s *SpendJournalPruner) NotifyConnectedBlock(blockHash *chainhash.Hash)
NotifyConnectedBlock signals the spend pruner of the provided connected block hash.
func (*SpendJournalPruner) RemoveSpendConsumerDependency ¶
func (s *SpendJournalPruner) RemoveSpendConsumerDependency(dbTx database.Tx, blockHash *chainhash.Hash, consumerID string) error
RemoveSpendConsumerDependency removes the provided spend consumer dependency associated with the provided block hash from the spend pruner. The block hash is removed as a key of the dependents map once all its dependency entries are removed.