Compare commits

...

2 Commits

Author SHA1 Message Date
4011597d9c
Check specific db error 2024-10-23 14:02:13 +03:00
176473aa26
Rename prefix to vouchers 2024-10-23 13:54:42 +03:00

View File

@ -640,10 +640,14 @@ func (h *Handlers) CheckBalance(ctx context.Context, sym string, input []byte) (
// get the active sym and active balance
activeSym, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACTIVE_SYM)
if err != nil {
if db.IsNotFound(err) {
res.Content = "0.00"
return res, nil
}
return res, err
}
activeBal, err := store.ReadEntry(ctx, sessionId, utils.DATA_ACTIVE_BAL)
if err != nil {
return res, nil
@ -1068,7 +1072,7 @@ func (h *Handlers) CheckVouchers(ctx context.Context, sym string, input []byte)
// process voucher data
voucherSymbolList, voucherBalanceList := ProcessVouchers(vouchersResp.Result.Holdings)
prefixdb := storage.NewSubPrefixDb(store, []byte("pfx"))
prefixdb := storage.NewSubPrefixDb(store, []byte("vouchers"))
err = prefixdb.Put(ctx, []byte("sym"), []byte(voucherSymbolList))
if err != nil {
return res, nil
@ -1108,7 +1112,7 @@ func (h *Handlers) GetVoucherList(ctx context.Context, sym string, input []byte)
// Read vouchers from the store
store := h.userdataStore
prefixdb := storage.NewSubPrefixDb(store, []byte("pfx"))
prefixdb := storage.NewSubPrefixDb(store, []byte("vouchers"))
voucherData, err := prefixdb.Get(ctx, []byte("sym"))
if err != nil {
@ -1139,7 +1143,7 @@ func (h *Handlers) ViewVoucher(ctx context.Context, sym string, input []byte) (r
return res, nil
}
prefixdb := storage.NewSubPrefixDb(store, []byte("pfx"))
prefixdb := storage.NewSubPrefixDb(store, []byte("vouchers"))
// Retrieve the voucher symbol list
voucherSymbolList, err := prefixdb.Get(ctx, []byte("sym"))