Skip to content

Commit c821b93

Browse files
committed
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.
1 parent 1930f49 commit c821b93

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

mempool/estimatefee.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,3 +756,6 @@ func RestoreFeeEstimator(data FeeEstimatorState) (*FeeEstimator, error) {
756756

757757
return ef, nil
758758
}
759+
760+
// Ensure FeeEstimator implements the TxFeeEstimator interface.
761+
var _ TxFeeEstimator = (*FeeEstimator)(nil)

mempool/orphan.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,6 @@ func (om *OrphanManager) ProcessOrphans(
427427

428428
return promoted, nil
429429
}
430+
431+
// Ensure OrphanManager implements the OrphanTxManager interface.
432+
var _ OrphanTxManager = (*OrphanManager)(nil)

0 commit comments

Comments
 (0)