mirror of
https://github.com/btcsuite/btcd.git
synced 2026-08-13 12:32:51 +02:00
mempool: add interface compliance checks for OrphanManager and FeeEstimator
In this commit, we add compile-time interface compliance checks for OrphanManager and FeeEstimator, ensuring they correctly implement the OrphanTxManager and TxFeeEstimator interfaces respectively. These var _ InterfaceType = (*ConcreteType)(nil) declarations are a Go idiom for compile-time interface verification. If OrphanManager doesn't implement all methods of OrphanTxManager, or FeeEstimator doesn't implement TxFeeEstimator, the code will fail to compile with a clear error message. This is particularly valuable during refactoring, as it ensures that if we change an interface method signature, all implementations are updated accordingly. The checks have zero runtime cost and serve as living documentation of the implementation relationships.
This commit is contained in:
parent
1930f49e09
commit
c821b93609
2 changed files with 6 additions and 0 deletions
|
|
@ -756,3 +756,6 @@ func RestoreFeeEstimator(data FeeEstimatorState) (*FeeEstimator, error) {
|
|||
|
||||
return ef, nil
|
||||
}
|
||||
|
||||
// Ensure FeeEstimator implements the TxFeeEstimator interface.
|
||||
var _ TxFeeEstimator = (*FeeEstimator)(nil)
|
||||
|
|
|
|||
|
|
@ -427,3 +427,6 @@ func (om *OrphanManager) ProcessOrphans(
|
|||
|
||||
return promoted, nil
|
||||
}
|
||||
|
||||
// Ensure OrphanManager implements the OrphanTxManager interface.
|
||||
var _ OrphanTxManager = (*OrphanManager)(nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue