Skip to content

Commit 0039a7a

Browse files
committed
Update SubmitIntent handler interfaces
1 parent 0b32d26 commit 0039a7a

File tree

3 files changed

+6
-66
lines changed

3 files changed

+6
-66
lines changed

pkg/code/server/transaction/action_handler.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ type CreateActionHandler interface {
6868
bh solana.Blockhash,
6969
) (*newFulfillmentMetadata, error)
7070

71-
// OnSaveToDB is a callback when the action is being saved to the DB
71+
// OnCommitToDB is a callback when the action is being committeds to the DB
7272
// within the scope of a DB transaction. Additional supporting DB records
7373
// (ie. not the action or fulfillment records) relevant to the action should
7474
// be saved here.
75-
OnSaveToDB(ctx context.Context) error
75+
OnCommitToDB(ctx context.Context) error
7676
}
7777

7878
type OpenAccountActionHandler struct {
@@ -172,7 +172,7 @@ func (h *OpenAccountActionHandler) GetFulfillmentMetadata(
172172
}
173173
}
174174

175-
func (h *OpenAccountActionHandler) OnSaveToDB(ctx context.Context) error {
175+
func (h *OpenAccountActionHandler) OnCommitToDB(ctx context.Context) error {
176176
err := h.data.SaveTimelock(ctx, h.unsavedTimelockRecord)
177177
if err != nil {
178178
return err
@@ -301,7 +301,7 @@ func (h *NoPrivacyTransferActionHandler) GetFulfillmentMetadata(
301301
}
302302
}
303303

304-
func (h *NoPrivacyTransferActionHandler) OnSaveToDB(ctx context.Context) error {
304+
func (h *NoPrivacyTransferActionHandler) OnCommitToDB(ctx context.Context) error {
305305
return nil
306306
}
307307

@@ -416,6 +416,6 @@ func (h *NoPrivacyWithdrawActionHandler) GetFulfillmentMetadata(
416416
}
417417
}
418418

419-
func (h *NoPrivacyWithdrawActionHandler) OnSaveToDB(ctx context.Context) error {
419+
func (h *NoPrivacyWithdrawActionHandler) OnCommitToDB(ctx context.Context) error {
420420
return nil
421421
}

pkg/code/server/transaction/intent.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,6 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm
598598
return err
599599
}
600600

601-
// Save additional state related to the intent
602-
err = intentHandler.OnSaveToDB(ctx, intentRecord)
603-
if err != nil {
604-
log.WithError(err).Warn("failure executing intent db save callback")
605-
return err
606-
}
607-
608601
// Save all actions
609602
err = s.data.PutAllActions(ctx, actionRecords...)
610603
if err != nil {
@@ -614,7 +607,7 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm
614607

615608
// Save additional state related to each action
616609
for _, actionHandler := range actionHandlers {
617-
err = actionHandler.OnSaveToDB(ctx)
610+
err = actionHandler.OnCommitToDB(ctx)
618611
if err != nil {
619612
log.WithError(err).Warn("failure executing action db save callback handler")
620613
return err
@@ -673,13 +666,6 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm
673666

674667
log.Debug("intent submitted")
675668

676-
// Post-processing when an intent has been committed to the DB.
677-
678-
err = intentHandler.OnCommittedToDB(ctx, intentRecord)
679-
if err != nil {
680-
log.WithError(err).Warn("failure executing intent committed callback handler handler")
681-
}
682-
683669
// Fire off some success metrics
684670
recordUserIntentCreatedEvent(ctx, intentRecord)
685671

pkg/code/server/transaction/intent_handler.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,6 @@ type CreateIntentHandler interface {
5959

6060
// AllowCreation determines whether the new intent creation should be allowed.
6161
AllowCreation(ctx context.Context, intentRecord *intent.Record, metadata *transactionpb.Metadata, actions []*transactionpb.Action) error
62-
63-
// OnSaveToDB is a callback when the intent is being saved to the DB
64-
// within the scope of a DB transaction. Additional supporting DB records
65-
// (ie. not the intent record) relevant to the intent should be saved here.
66-
OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error
67-
68-
// OnCommittedToDB is a callback when the intent has been committed to the
69-
// DB. Any instant side-effects should called here, and can be done async
70-
// in a new goroutine to not affect SubmitIntent latency.
71-
//
72-
// Note: Any errors generated here have no effect on rolling back the intent.
73-
// This is all best-effort up to this point. Use a worker for things
74-
// requiring retries!
75-
OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error
7662
}
7763

7864
type OpenAccountsIntentHandler struct {
@@ -294,14 +280,6 @@ func (h *OpenAccountsIntentHandler) validateActions(
294280
return nil
295281
}
296282

297-
func (h *OpenAccountsIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error {
298-
return nil
299-
}
300-
301-
func (h *OpenAccountsIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error {
302-
return nil
303-
}
304-
305283
type SendPublicPaymentIntentHandler struct {
306284
conf *conf
307285
data code_data.Provider
@@ -791,14 +769,6 @@ func (h *SendPublicPaymentIntentHandler) validateActions(
791769
return nil
792770
}
793771

794-
func (h *SendPublicPaymentIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error {
795-
return nil
796-
}
797-
798-
func (h *SendPublicPaymentIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error {
799-
return nil
800-
}
801-
802772
type ReceivePaymentsPubliclyIntentHandler struct {
803773
conf *conf
804774
data code_data.Provider
@@ -1084,14 +1054,6 @@ func (h *ReceivePaymentsPubliclyIntentHandler) validateActions(
10841054
return validateMoneyMovementActionUserAccounts(intent.ReceivePaymentsPublicly, initiatorAccountsByVault, actions)
10851055
}
10861056

1087-
func (h *ReceivePaymentsPubliclyIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error {
1088-
return nil
1089-
}
1090-
1091-
func (h *ReceivePaymentsPubliclyIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error {
1092-
return nil
1093-
}
1094-
10951057
type PublicDistributionIntentHandler struct {
10961058
conf *conf
10971059
data code_data.Provider
@@ -1380,14 +1342,6 @@ func (h *PublicDistributionIntentHandler) validateActions(
13801342
return nil
13811343
}
13821344

1383-
func (h *PublicDistributionIntentHandler) OnSaveToDB(ctx context.Context, intentRecord *intent.Record) error {
1384-
return nil
1385-
}
1386-
1387-
func (h *PublicDistributionIntentHandler) OnCommittedToDB(ctx context.Context, intentRecord *intent.Record) error {
1388-
return nil
1389-
}
1390-
13911345
func validateAllUserAccountsManagedByCode(ctx context.Context, initiatorAccounts []*common.AccountRecords) error {
13921346
// Try to unlock *ANY* latest account, and you're done
13931347
for _, accountRecords := range initiatorAccounts {

0 commit comments

Comments
 (0)