multi: query mempool spend when a new input is received

This commit changes how a new input sweep request is handled - now we
will query the mempool and see if it's already been spent. If so, we'll
update its state as we may need to RBF this input.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:22 +08:00
1 parent 6a2e3fb203
commit 47478718d4
4 files changed
+180 -5

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
package chainntnfs
import (
"github.com/btcsuite/btcd/wire"
"github.com/stretchr/testify/mock"
)
// MockMempoolWatcher is a mock implementation of the MempoolWatcher interface.
// This is used by other subsystems to mock the behavior of the mempool
// watcher.
type MockMempoolWatcher struct {
mock.Mock
}
// NewMockMempoolWatcher returns a new instance of a mock mempool watcher.
func NewMockMempoolWatcher() *MockMempoolWatcher {
return &MockMempoolWatcher{}
}
// Compile-time check to ensure MockMempoolWatcher implements MempoolWatcher.
var _ MempoolWatcher = (*MockMempoolWatcher)(nil)
// SubscribeMempoolSpent implements the MempoolWatcher interface.
func (m *MockMempoolWatcher) SubscribeMempoolSpent(
op wire.OutPoint) (*MempoolSpendEvent, error) {
args := m.Called(op)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*MempoolSpendEvent), args.Error(1)
}
// CancelMempoolSpendEvent implements the MempoolWatcher interface.
func (m *MockMempoolWatcher) CancelMempoolSpendEvent(
sub *MempoolSpendEvent) {
m.Called(sub)
}