forked from urdt/ussd
Removed redundant naming of transfer related data
This commit is contained in:
parent
caff27b43d
commit
14737b5f12
16
common/db.go
16
common/db.go
@ -37,14 +37,14 @@ const (
|
|||||||
DATA_VOUCHER_BALANCES
|
DATA_VOUCHER_BALANCES
|
||||||
DATA_VOUCHER_DECIMALS
|
DATA_VOUCHER_DECIMALS
|
||||||
DATA_VOUCHER_ADDRESSES
|
DATA_VOUCHER_ADDRESSES
|
||||||
DATA_PREFIX_TX_SENDERS
|
DATA_TX_SENDERS
|
||||||
DATA_PREFIX_TX_RECIPIENTS
|
DATA_TX_RECIPIENTS
|
||||||
DATA_PREFIX_TX_VALUES
|
DATA_TX_VALUES
|
||||||
DATA_PREFIX_TX_ADDRESSES
|
DATA_TX_ADDRESSES
|
||||||
DATA_PREFIX_TX_HASHES
|
DATA_TX_HASHES
|
||||||
DATA_PREFIX_TX_DATES
|
DATA_TX_DATES
|
||||||
DATA_PREFIX_TX_SYMBOLS
|
DATA_TX_SYMBOLS
|
||||||
DATA_PREFIX_TX_DECIMALS
|
DATA_TX_DECIMALS
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -57,7 +57,7 @@ func ProcessTransfers(transfers []dataserviceapi.Last10TxResponse) TransferMetad
|
|||||||
// GetTransferData retrieves and matches transfer data
|
// GetTransferData retrieves and matches transfer data
|
||||||
// returns a formatted string of the full transaction/statement
|
// returns a formatted string of the full transaction/statement
|
||||||
func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, index int) (string, error) {
|
func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string, index int) (string, error) {
|
||||||
keys := []DataTyp{DATA_PREFIX_TX_SENDERS, DATA_PREFIX_TX_RECIPIENTS, DATA_PREFIX_TX_VALUES, DATA_PREFIX_TX_ADDRESSES, DATA_PREFIX_TX_HASHES, DATA_PREFIX_TX_DATES, DATA_PREFIX_TX_SYMBOLS}
|
keys := []DataTyp{DATA_TX_SENDERS, DATA_TX_RECIPIENTS, DATA_TX_VALUES, DATA_TX_ADDRESSES, DATA_TX_HASHES, DATA_TX_DATES, DATA_TX_SYMBOLS}
|
||||||
data := make(map[DataTyp]string)
|
data := make(map[DataTyp]string)
|
||||||
|
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
@ -69,13 +69,13 @@ func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Split the data
|
// Split the data
|
||||||
senders := strings.Split(string(data[DATA_PREFIX_TX_SENDERS]), "\n")
|
senders := strings.Split(string(data[DATA_TX_SENDERS]), "\n")
|
||||||
recipients := strings.Split(string(data[DATA_PREFIX_TX_RECIPIENTS]), "\n")
|
recipients := strings.Split(string(data[DATA_TX_RECIPIENTS]), "\n")
|
||||||
values := strings.Split(string(data[DATA_PREFIX_TX_VALUES]), "\n")
|
values := strings.Split(string(data[DATA_TX_VALUES]), "\n")
|
||||||
addresses := strings.Split(string(data[DATA_PREFIX_TX_ADDRESSES]), "\n")
|
addresses := strings.Split(string(data[DATA_TX_ADDRESSES]), "\n")
|
||||||
hashes := strings.Split(string(data[DATA_PREFIX_TX_HASHES]), "\n")
|
hashes := strings.Split(string(data[DATA_TX_HASHES]), "\n")
|
||||||
dates := strings.Split(string(data[DATA_PREFIX_TX_DATES]), "\n")
|
dates := strings.Split(string(data[DATA_TX_DATES]), "\n")
|
||||||
syms := strings.Split(string(data[DATA_PREFIX_TX_SYMBOLS]), "\n")
|
syms := strings.Split(string(data[DATA_TX_SYMBOLS]), "\n")
|
||||||
|
|
||||||
// Check if index is within range
|
// Check if index is within range
|
||||||
if index < 1 || index > len(senders) {
|
if index < 1 || index > len(senders) {
|
||||||
|
@ -1746,14 +1746,14 @@ func (h *Handlers) CheckTransactions(ctx context.Context, sym string, input []by
|
|||||||
|
|
||||||
// Store all transaction data
|
// Store all transaction data
|
||||||
dataMap := map[common.DataTyp]string{
|
dataMap := map[common.DataTyp]string{
|
||||||
common.DATA_PREFIX_TX_SENDERS: data.Senders,
|
common.DATA_TX_SENDERS: data.Senders,
|
||||||
common.DATA_PREFIX_TX_RECIPIENTS: data.Recipients,
|
common.DATA_TX_RECIPIENTS: data.Recipients,
|
||||||
common.DATA_PREFIX_TX_VALUES: data.TransferValues,
|
common.DATA_TX_VALUES: data.TransferValues,
|
||||||
common.DATA_PREFIX_TX_ADDRESSES: data.Addresses,
|
common.DATA_TX_ADDRESSES: data.Addresses,
|
||||||
common.DATA_PREFIX_TX_HASHES: data.TxHashes,
|
common.DATA_TX_HASHES: data.TxHashes,
|
||||||
common.DATA_PREFIX_TX_DATES: data.Dates,
|
common.DATA_TX_DATES: data.Dates,
|
||||||
common.DATA_PREFIX_TX_SYMBOLS: data.Symbols,
|
common.DATA_TX_SYMBOLS: data.Symbols,
|
||||||
common.DATA_PREFIX_TX_DECIMALS: data.Decimals,
|
common.DATA_TX_DECIMALS: data.Decimals,
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range dataMap {
|
for key, value := range dataMap {
|
||||||
@ -1783,22 +1783,22 @@ func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input []
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read transactions from the store and format them
|
// Read transactions from the store and format them
|
||||||
TransactionSenders, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_SENDERS))
|
TransactionSenders, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_SENDERS))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "Failed to read the TransactionSenders from prefixDb", "error", err)
|
logg.ErrorCtxf(ctx, "Failed to read the TransactionSenders from prefixDb", "error", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
TransactionSyms, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_SYMBOLS))
|
TransactionSyms, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_SYMBOLS))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "Failed to read the TransactionSyms from prefixDb", "error", err)
|
logg.ErrorCtxf(ctx, "Failed to read the TransactionSyms from prefixDb", "error", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
TransactionValues, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_VALUES))
|
TransactionValues, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_VALUES))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "Failed to read the TransactionValues from prefixDb", "error", err)
|
logg.ErrorCtxf(ctx, "Failed to read the TransactionValues from prefixDb", "error", err)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
TransactionDates, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_PREFIX_TX_DATES))
|
TransactionDates, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_TX_DATES))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "Failed to read the TransactionDates from prefixDb", "error", err)
|
logg.ErrorCtxf(ctx, "Failed to read the TransactionDates from prefixDb", "error", err)
|
||||||
return res, err
|
return res, err
|
||||||
|
Loading…
Reference in New Issue
Block a user