Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
fix(BUX-250): remove p2pNotify cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Nov 13, 2023
1 parent 483fbf7 commit 35a96f1
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 68 deletions.
1 change: 0 additions & 1 deletion client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func defaultClientOptions() *clientOptions {
ModelDraftTransaction.String() + "_clean_up": taskIntervalDraftCleanup,
ModelIncomingTransaction.String() + "_process": taskIntervalProcessIncomingTxs,
ModelSyncTransaction.String() + "_" + syncActionBroadcast: taskIntervalSyncActionBroadcast,
ModelSyncTransaction.String() + "_" + syncActionP2P: taskIntervalSyncActionP2P,
ModelSyncTransaction.String() + "_" + syncActionSync: taskIntervalSyncActionSync,
ModelTransaction.String() + "_" + TransactionActionCheck: taskIntervalTransactionCheck,
},
Expand Down
1 change: 0 additions & 1 deletion definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const (
taskIntervalMonitorCheck = defaultMonitorHeartbeat * time.Second // Default task time for cron jobs (seconds)
taskIntervalProcessIncomingTxs = 30 * time.Second // Default task time for cron jobs (seconds)
taskIntervalSyncActionBroadcast = 30 * time.Second // Default task time for cron jobs (seconds)
taskIntervalSyncActionP2P = 35 * time.Second // Default task time for cron jobs (seconds)
taskIntervalSyncActionSync = 40 * time.Second // Default task time for cron jobs (seconds)
taskIntervalTransactionCheck = 60 * time.Second // Default task time for cron jobs (seconds)
)
Expand Down
26 changes: 3 additions & 23 deletions model_sync_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (m *SyncTransaction) RegisterTasks() error {
return nil
}

// Sync with chain - task
// Register the task locally (cron task - set the defaults)
syncTask := m.Name() + "_" + syncActionSync
ctx := context.Background()
Expand Down Expand Up @@ -171,6 +172,7 @@ func (m *SyncTransaction) RegisterTasks() error {
return err
}

// Broadcast - task
// Register the task locally (cron task - set the defaults)
broadcastTask := m.Name() + "_" + syncActionBroadcast

Expand All @@ -197,27 +199,5 @@ func (m *SyncTransaction) RegisterTasks() error {
return err
}

// Register the task locally (cron task - set the defaults)
p2pTask := m.Name() + "_" + syncActionP2P

// Register the task
if err = tm.RegisterTask(&taskmanager.Task{
Name: p2pTask,
RetryLimit: 1,
Handler: func(client ClientInterface) error {
if taskErr := taskNotifyP2P(ctx, client.Logger(), WithClient(client)); taskErr != nil {
client.Logger().Error(ctx, "error running "+p2pTask+" task: "+taskErr.Error())
}
return nil
},
}); err != nil {
return err
}

// Run the task periodically
return tm.RunTask(ctx, &taskmanager.TaskOptions{
Arguments: []interface{}{m.Client()},
RunEveryPeriod: m.Client().GetTaskPeriod(p2pTask),
TaskName: p2pTask,
})
return nil
}
31 changes: 0 additions & 31 deletions sync_tx_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,37 +96,6 @@ func processBroadcastTransactions(ctx context.Context, maxTransactions int, opts
return nil
}

// processP2PTransactions will process transactions for p2p notifications
func processP2PTransactions(ctx context.Context, maxTransactions int, opts ...ModelOps) error {
queryParams := &datastore.QueryParams{
Page: 1,
PageSize: maxTransactions,
OrderByField: "created_at",
SortDirection: "asc",
}

// Get x records
records, err := getTransactionsToNotifyP2P(
ctx, queryParams, opts...,
)
if err != nil {
return err
} else if len(records) == 0 {
return nil
}

// Process the incoming transaction
for index := range records {
if err = processP2PTransaction(
ctx, records[index], nil,
); err != nil {
return err
}
}

return nil
}

// broadcastSyncTransaction will broadcast transaction related to syncTx record
func broadcastSyncTransaction(ctx context.Context, syncTx *SyncTransaction) error {
// Successfully capture any panics, convert to readable string and log the error
Expand Down
12 changes: 0 additions & 12 deletions tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,6 @@ func taskBroadcastTransactions(ctx context.Context, logClient zLogger.GormLogger
return err
}

// taskNotifyP2P will notify any p2p paymail providers
func taskNotifyP2P(ctx context.Context, logClient zLogger.GormLoggerInterface, opts ...ModelOps) error {

logClient.Info(ctx, "running notify p2p paymail provider(s) task...")

err := processP2PTransactions(ctx, 10, opts...)
if err == nil || errors.Is(err, datastore.ErrNoResults) {
return nil
}
return err
}

// taskSyncTransactions will sync any transactions
func taskSyncTransactions(ctx context.Context, logClient zLogger.GormLoggerInterface, opts ...ModelOps) error {

Expand Down

0 comments on commit 35a96f1

Please sign in to comment.