From 47f78739a58e72b130d54fe2aa581915b1e6c042 Mon Sep 17 00:00:00 2001 From: Matthias <5011972+fasmat@users.noreply.github.com> Date: Mon, 6 May 2024 09:34:33 +0000 Subject: [PATCH] Don't store ATX if check malicious fails --- activation/handler.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/activation/handler.go b/activation/handler.go index dff08691..a650b46b 100644 --- a/activation/handler.go +++ b/activation/handler.go @@ -565,13 +565,16 @@ func (h *Handler) storeAtx(ctx context.Context, atx *types.VerifiedActivationTx) var nonce *types.VRFPostIndex var proof *mwire.MalfeasanceProof err := h.cdb.WithTx(ctx, func(tx *sql.Tx) error { - var err1, err2 error - proof, err1 = h.checkMalicious(ctx, tx, atx) - nonce, err2 = atxs.AddGettingNonce(tx, atx) - if err2 != nil && !errors.Is(err2, sql.ErrObjectExists) { - err2 = fmt.Errorf("add atx to db: %w", err2) + var err error + proof, err = h.checkMalicious(ctx, tx, atx) + if err != nil { + return fmt.Errorf("check malicious: %w", err) } - return errors.Join(err1, err2) + nonce, err = atxs.AddGettingNonce(tx, atx) + if err != nil && !errors.Is(err, sql.ErrObjectExists) { + return fmt.Errorf("add atx to db: %w", err) + } + return nil }) if err != nil { return nil, fmt.Errorf("store atx: %w", err)