Skip to content

Commit 04097f4

Browse files
authored
fix(pstorage): add colon for better error formating (#292)
fix file mode for bbolt file <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved error handling to prevent unnecessary error messages when saving existing account data. - Enhanced error messages for account and certificate operations to provide clearer information. - **Chores** - Updated file permissions for database files to ensure secure access. - Improved internal error logging for better visibility of account query issues. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Artur Troian <[email protected]> Co-authored-by: Artur Troian <[email protected]>
1 parent 47b7ae4 commit 04097f4

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

cmd/provider-services/cmd/certs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func (c *accountQuerier) run() error {
311311
}
312312
case acc := <-accountRespCh:
313313
err := pstorage.AddAccount(c.ctx, acc.GetAddress(), acc.GetPubKey())
314-
if err != nil {
314+
if err != nil && !errors.Is(err, pconfig.ErrExists) {
315315
c.log.Error("unable to save account pubkey into storage", "owner", acc.GetAddress().String(), "err", err)
316316
}
317317
case req := <-c.peerCertCh:
@@ -466,12 +466,14 @@ func (c *accountQuerier) accountQuerier(reqch <-chan sdk.Address, respch chan<-
466466

467467
res, err := c.qc.Query().Auth().Account(c.ctx, &authtypes.QueryAccountRequest{Address: addr.String()})
468468
if err != nil {
469+
c.log.Error("fetching account info", "err", err.Error(), "account", addr.String())
469470
requests = append(requests, addr)
470471
continue
471472
}
472473

473474
var acc authtypes.AccountI
474475
if err := cctx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil {
476+
c.log.Error("unpacking account info", "err", err.Error(), "account", addr.String())
475477
requests = append(requests, addr)
476478
continue
477479
}

tools/pconfig/bbolt/bbolt.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"errors"
1010
"fmt"
1111
"math/big"
12-
"os"
1312

1413
ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3"
1514
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@@ -50,7 +49,7 @@ type account struct {
5049
}
5150

5251
func NewBBolt(path string) (pconfig.Storage, error) {
53-
db, err := bbolt.Open(path, os.ModeType, nil)
52+
db, err := bbolt.Open(path, 0600, nil)
5453
if err != nil {
5554
return nil, err
5655
}

tools/pconfig/pconfig.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ var (
1616
ErrInvalidArgs = errors.New("pstorage: invalid arguments")
1717
ErrNotExists = errors.New("pstorage: not exists")
1818
ErrExists = errors.New("pstorage: exists")
19-
ErrAccountNotExists = fmt.Errorf("%w account", ErrNotExists)
20-
ErrAccountExists = fmt.Errorf("%w account", ErrExists)
21-
ErrCertificateNotExists = fmt.Errorf("%w certificate", ErrNotExists)
22-
ErrCertificateExists = fmt.Errorf("%w certificate", ErrExists)
19+
ErrAccountNotExists = fmt.Errorf("%w: account", ErrNotExists)
20+
ErrAccountExists = fmt.Errorf("%w: account", ErrExists)
21+
ErrCertificateNotExists = fmt.Errorf("%w: certificate", ErrNotExists)
22+
ErrCertificateExists = fmt.Errorf("%w: certificate", ErrExists)
2323
)
2424

2525
type StorageR interface {

0 commit comments

Comments
 (0)