data-items-cleanup #203

Merged
lash merged 12 commits from data-items-cleanup into master 2024-12-05 16:03:50 +01:00
3 changed files with 28 additions and 28 deletions
Showing only changes of commit 14737b5f12 - Show all commits

View File

@ -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
Alfred-mk marked this conversation as resolved Outdated
Outdated
Review

Sorry perhaps it wasn't clear. The "PREFIX" part in general is implied and a thus redundant. TX should suffice.

Sorry perhaps it wasn't clear. The "PREFIX" part in general is implied and a thus redundant. TX should suffice.

Apologies, I was to replace these as well. This has been done

Apologies, I was to replace these as well. This has been done
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 (

View File

@ -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) {

View File

@ -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