From d646bb20001e3a2998b599720dfcd37aa4f0e256 Mon Sep 17 00:00:00 2001 From: envestcc Date: Thu, 25 Jan 2024 23:52:00 +0800 Subject: [PATCH] address comment --- action/protocol/staking/protocol.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/action/protocol/staking/protocol.go b/action/protocol/staking/protocol.go index 35dfc223b6..1c6a694cf3 100644 --- a/action/protocol/staking/protocol.go +++ b/action/protocol/staking/protocol.go @@ -56,8 +56,9 @@ const ( // Errors var ( - ErrWithdrawnBucket = errors.New("the bucket is already withdrawn") - TotalBucketKey = append([]byte{_const}, []byte("totalBucket")...) + ErrWithdrawnBucket = errors.New("the bucket is already withdrawn") + ErrEndorsementNotExist = errors.New("the endorsement does not exist") + TotalBucketKey = append([]byte{_const}, []byte("totalBucket")...) ) var ( @@ -485,10 +486,7 @@ func (p *Protocol) isActiveCandidate(ctx context.Context, csr CandidateStateRead } vb, err := csr.getBucket(cand.SelfStakeBucketIdx) if err != nil { - if errors.Is(err, state.ErrStateNotExist) { - return false, nil - } - return false, err + return false, errors.Wrapf(err, "failed to get bucket %d", cand.SelfStakeBucketIdx) } // bucket is self-owned if address.Equal(vb.Owner, cand.Owner) { @@ -509,7 +507,7 @@ func (p *Protocol) isActiveCandidate(ctx context.Context, csr CandidateStateRead return false, err default: // endorsement does not exist - return false, errors.New("endorsement does not exist") + return false, errors.Wrapf(ErrEndorsementNotExist, "bucket index %d", cand.SelfStakeBucketIdx) } return true, nil }