Skip to content

Commit

Permalink
Merge pull request #244 from bitcoin-sv/send-rejected-callback
Browse files Browse the repository at this point in the history
remove rejected transaction from store and send callback about that s…
  • Loading branch information
shotasilagadzetaal authored Jan 10, 2024
2 parents da7989c + e684e87 commit aad5d05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion metamorph/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,11 @@ func (p *Processor) SendStatusForTransaction(hash *chainhash.Hash, status metamo

case metamorph_api.Status_REJECTED:
p.logger.Warn("transaction rejected", slog.String("status", status.String()), slog.String("hash", hash.String()))

p.rejected.AddDuration(source, time.Since(processorResponse.Start))
data, _ := p.store.Get(spanCtx, hash[:])
if data.CallbackUrl != "" {
go SendCallback(p.logger, p.store, data)
}
}
},
}
Expand Down
3 changes: 3 additions & 0 deletions metamorph/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ func TestSendStatusForTransaction(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(tc.expectedUpdateStatusCalls)
metamorphStore := &MetamorphStoreMock{
GetFunc: func(ctx context.Context, key []byte) (*store.StoreData, error) {
return &store.StoreData{Hash: testdata.TX2Hash}, nil
},
UpdateStatusFunc: func(ctx context.Context, hash *chainhash.Hash, status metamorph_api.Status, rejectReason string) error {
require.Equal(t, tc.txResponseHash, hash)
wg.Done()
Expand Down

0 comments on commit aad5d05

Please sign in to comment.