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:
Olaoluwa Osuntokun 2025-10-03 16:51:17 -07:00
parent 1930f49e09
commit c821b93609
2 changed files with 6 additions and 0 deletions

View file

@ -756,3 +756,6 @@ func RestoreFeeEstimator(data FeeEstimatorState) (*FeeEstimator, error) {
return ef, nil
}
// Ensure FeeEstimator implements the TxFeeEstimator interface.
var _ TxFeeEstimator = (*FeeEstimator)(nil)

View file

@ -427,3 +427,6 @@ func (om *OrphanManager) ProcessOrphans(
return promoted, nil
}
// Ensure OrphanManager implements the OrphanTxManager interface.
var _ OrphanTxManager = (*OrphanManager)(nil)