mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 04:34:19 +01:00
returns forfeitsTxs in Ping RPC while the finalization started (#161)
This commit is contained in:
11
server/internal/core/application/errors.go
Normal file
11
server/internal/core/application/errors.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package application
|
||||
|
||||
import "fmt"
|
||||
|
||||
type errPaymentNotFound struct {
|
||||
id string
|
||||
}
|
||||
|
||||
func (e errPaymentNotFound) Error() string {
|
||||
return fmt.Sprintf("payment %s not found", e.id)
|
||||
}
|
||||
@@ -34,7 +34,7 @@ type Service interface {
|
||||
GetRoundByTxid(ctx context.Context, poolTxid string) (*domain.Round, error)
|
||||
GetCurrentRound(ctx context.Context) (*domain.Round, error)
|
||||
GetEventsChannel(ctx context.Context) <-chan domain.RoundEvent
|
||||
UpdatePaymentStatus(ctx context.Context, id string) error
|
||||
UpdatePaymentStatus(ctx context.Context, id string) (unsignedForfeitTxs []string, err error)
|
||||
ListVtxos(ctx context.Context, pubkey *secp256k1.PublicKey) ([]domain.Vtxo, []domain.Vtxo, error)
|
||||
GetInfo(ctx context.Context) (string, int64, int64, error)
|
||||
Onboard(ctx context.Context, boardingTx string, congestionTree tree.CongestionTree, userPubkey *secp256k1.PublicKey) error
|
||||
@@ -178,8 +178,17 @@ func (s *service) ClaimVtxos(ctx context.Context, creds string, receivers []doma
|
||||
return s.paymentRequests.update(*payment)
|
||||
}
|
||||
|
||||
func (s *service) UpdatePaymentStatus(_ context.Context, id string) error {
|
||||
return s.paymentRequests.updatePingTimestamp(id)
|
||||
func (s *service) UpdatePaymentStatus(_ context.Context, id string) ([]string, error) {
|
||||
err := s.paymentRequests.updatePingTimestamp(id)
|
||||
if err != nil {
|
||||
if _, ok := err.(errPaymentNotFound); ok {
|
||||
return s.forfeitTxs.view(), nil
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *service) SignVtxos(ctx context.Context, forfeitTxs []string) error {
|
||||
|
||||
@@ -110,7 +110,7 @@ func (m *paymentsMap) updatePingTimestamp(id string) error {
|
||||
|
||||
payment, ok := m.payments[id]
|
||||
if !ok {
|
||||
return fmt.Errorf("payment %s not found", id)
|
||||
return errPaymentNotFound{id}
|
||||
}
|
||||
|
||||
payment.pingTimestamp = time.Now()
|
||||
|
||||
Reference in New Issue
Block a user