From 579bf021a7ad8ff7ab0f3ac28817417514277d51 Mon Sep 17 00:00:00 2001 From: Nazarii-4chain Date: Mon, 29 Jan 2024 14:57:06 +0200 Subject: [PATCH 1/5] Changed error message --- action_paymails.go | 2 +- errors.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/action_paymails.go b/action_paymails.go index 85231636..96a7666c 100644 --- a/action_paymails.go +++ b/action_paymails.go @@ -142,7 +142,7 @@ func (c *Client) DeletePaymailAddress(ctx context.Context, address string, opts if err != nil { return err } else if paymailAddress == nil { - return ErrMissingPaymail + return ErrPaymailNotFound } // todo: make a better approach for deleting paymail addresses? diff --git a/errors.go b/errors.go index 17562034..98c6b38e 100644 --- a/errors.go +++ b/errors.go @@ -97,6 +97,9 @@ var ErrDuplicateUTXOs = errors.New("duplicate utxos found") // ErrPaymailAddressIsInvalid is when the paymail address is NOT alias@domain.com var ErrPaymailAddressIsInvalid = errors.New("paymail address is invalid") +// ErrPaymailNotFound is when paymaail could not be found +var ErrPaymailNotFound = errors.New("paymail could not be found") + // ErrUtxoNotReserved is when the utxo is not reserved, but a transaction tries to spend it var ErrUtxoNotReserved = errors.New("transaction utxo has not been reserved for spending") From adb5dd230ef01a565d33e8eaf66398c3937d69ec Mon Sep 17 00:00:00 2001 From: Nazarii-4chain Date: Tue, 30 Jan 2024 10:46:01 +0200 Subject: [PATCH 2/5] Changed tests --- action_paymails_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action_paymails_test.go b/action_paymails_test.go index f295f96f..e6786cca 100644 --- a/action_paymails_test.go +++ b/action_paymails_test.go @@ -29,7 +29,7 @@ func (ts *EmbeddedDBTestSuite) TestClient_NewPaymailAddress() { var paymailAddress *PaymailAddress paymailAddress, err = tc.client.NewPaymailAddress(tc.ctx, testXPub, "", testPublicName, testAvatar, tc.client.DefaultModelOptions()...) - require.ErrorIs(t, err, ErrMissingPaymailAddress) + require.ErrorIs(t, err, ErrPaymailNotFound) require.Nil(t, paymailAddress) }) @@ -81,7 +81,7 @@ func (ts *EmbeddedDBTestSuite) Test_DeletePaymailAddress() { paymail := "" err := tc.client.DeletePaymailAddress(tc.ctx, paymail, tc.client.DefaultModelOptions()...) - require.ErrorIs(t, err, ErrMissingPaymail) + require.ErrorIs(t, err, ErrPaymailNotFound) }) ts.T().Run(testCase.name+" - delete unknown paymail address", func(t *testing.T) { @@ -89,7 +89,7 @@ func (ts *EmbeddedDBTestSuite) Test_DeletePaymailAddress() { defer tc.Close(tc.ctx) err := tc.client.DeletePaymailAddress(tc.ctx, testPaymail, tc.client.DefaultModelOptions()...) - require.ErrorIs(t, err, ErrMissingPaymail) + require.ErrorIs(t, err, ErrPaymailNotFound) }) ts.T().Run(testCase.name+" - delete paymail address", func(t *testing.T) { From f14066eda3e33159f7b9adf4cc234f4549668d25 Mon Sep 17 00:00:00 2001 From: Nazarii-4chain Date: Tue, 30 Jan 2024 11:34:57 +0200 Subject: [PATCH 3/5] Changed tests --- action_paymails_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action_paymails_test.go b/action_paymails_test.go index e6786cca..7b953721 100644 --- a/action_paymails_test.go +++ b/action_paymails_test.go @@ -29,7 +29,7 @@ func (ts *EmbeddedDBTestSuite) TestClient_NewPaymailAddress() { var paymailAddress *PaymailAddress paymailAddress, err = tc.client.NewPaymailAddress(tc.ctx, testXPub, "", testPublicName, testAvatar, tc.client.DefaultModelOptions()...) - require.ErrorIs(t, err, ErrPaymailNotFound) + require.ErrorIs(t, err, ErrMissingPaymailAddress) require.Nil(t, paymailAddress) }) From 9a36866af25ad221891429df9c905462fe710b5c Mon Sep 17 00:00:00 2001 From: Nazarii-4chain Date: Thu, 1 Feb 2024 10:37:28 +0200 Subject: [PATCH 4/5] Renamed message --- action_paymails.go | 6 +++--- errors.go | 3 --- paymail_service_provider.go | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/action_paymails.go b/action_paymails.go index 96a7666c..11906981 100644 --- a/action_paymails.go +++ b/action_paymails.go @@ -20,7 +20,7 @@ func (c *Client) GetPaymailAddress(ctx context.Context, address string, opts ... if err != nil { return nil, err } else if paymailAddress == nil { - return nil, ErrMissingPaymail + return nil, ErrPaymailNotFound } return paymailAddress, nil @@ -174,7 +174,7 @@ func (c *Client) UpdatePaymailAddressMetadata(ctx context.Context, address strin if err != nil { return nil, err } else if paymailAddress == nil { - return nil, ErrMissingPaymail + return nil, ErrPaymailNotFound } // Update the metadata @@ -200,7 +200,7 @@ func (c *Client) UpdatePaymailAddress(ctx context.Context, address, publicName, if err != nil { return nil, err } else if paymailAddress == nil { - return nil, ErrMissingPaymail + return nil, ErrPaymailNotFound } // Update the public name diff --git a/errors.go b/errors.go index 98c6b38e..737c3718 100644 --- a/errors.go +++ b/errors.go @@ -172,9 +172,6 @@ var ErrUnknownAccessKey = errors.New("unknown access key") // ErrAccessKeyRevoked is when the access key has been revoked var ErrAccessKeyRevoked = errors.New("access key has been revoked") -// ErrMissingPaymail missing paymail -var ErrMissingPaymail = errors.New("missing paymail") - // ErrMissingPaymailID missing id in paymail var ErrMissingPaymailID = errors.New("missing id in paymail") diff --git a/paymail_service_provider.go b/paymail_service_provider.go index 5c8bd1b7..d71db497 100644 --- a/paymail_service_provider.go +++ b/paymail_service_provider.go @@ -207,7 +207,7 @@ func (p *PaymailDefaultServiceProvider) createPaymailInformation(ctx context.Con if err != nil { return nil, nil, err } else if paymailAddress == nil { - return nil, nil, ErrMissingPaymail + return nil, nil, ErrPaymailNotFound } unlock, err := newWaitWriteLock(ctx, lockKey(paymailAddress), p.client.Cachestore()) From 4145d5405ee57d82ad388d6fbb5f718e1fcb6b07 Mon Sep 17 00:00:00 2001 From: arkadiuszos4chain Date: Fri, 2 Feb 2024 10:29:59 +0100 Subject: [PATCH 5/5] fix: try broadcast outgoing tx again --- cron_job_declarations.go | 6 +++--- sync_tx_service.go | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cron_job_declarations.go b/cron_job_declarations.go index 0f1abe30..08385435 100644 --- a/cron_job_declarations.go +++ b/cron_job_declarations.go @@ -32,15 +32,15 @@ func (c *Client) cronJobs() taskmanager.CronJobs { Handler: handler(taskCleanupDraftTransactions), }, CronJobNameIncomingTransaction: { - Period: 30 * time.Second, + Period: 2 * time.Minute, Handler: handler(taskProcessIncomingTransactions), }, CronJobNameSyncTransactionBroadcast: { - Period: 30 * time.Second, + Period: 2 * time.Minute, Handler: handler(taskBroadcastTransactions), }, CronJobNameSyncTransactionSync: { - Period: 120 * time.Second, + Period: 5 * time.Minute, Handler: handler(taskSyncTransactions), }, } diff --git a/sync_tx_service.go b/sync_tx_service.go index 9f707d65..f2cfe20d 100644 --- a/sync_tx_service.go +++ b/sync_tx_service.go @@ -136,9 +136,7 @@ func broadcastSyncTransaction(ctx context.Context, syncTx *SyncTransaction) erro if provider, err = syncTx.Client().Chainstate().Broadcast( ctx, syncTx.ID, txHex, defaultBroadcastTimeout, ); err != nil { - _bailAndSaveSyncTransaction( - ctx, syncTx, SyncStatusError, syncActionBroadcast, provider, "broadcast error: "+err.Error(), - ) + _bailAndSaveSyncTransaction(ctx, syncTx, SyncStatusReady, syncActionBroadcast, provider, err.Error()) return err }