Skip to content

Commit 23d7794

Browse files
committed
fixes
1 parent 71ad1ca commit 23d7794

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

process/elasticproc/transactions/transactionDBBuilder.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ func newTransactionDBBuilder(
3636
}
3737
}
3838

39-
func (dtb *dbTransactionBuilder) prepareUnexecutableTransaction(txHash []byte, tx *transaction.Transaction, headerData *data.HeaderData) *data.Transaction {
39+
func (dtb *dbTransactionBuilder) prepareUnexecutableTransaction(txHashHex string, tx *transaction.Transaction, headerData *data.HeaderData) *data.Transaction {
4040
res := dtb.dataFieldParser.Parse(tx.Data, tx.SndAddr, tx.RcvAddr, headerData.NumberOfShards)
4141
receiversAddr, _ := dtb.addressPubkeyConverter.EncodeSlice(res.Receivers)
4242

4343
valueNum, err := dtb.balanceConverter.ConvertBigValueToFloat(tx.Value)
4444
if err != nil {
4545
log.Warn("dbTransactionBuilder.prepareUnexecutableTransaction: cannot compute value as num", "value", tx.Value,
46-
"hash", txHash, "error", err)
46+
"hash", txHashHex, "error", err)
4747
}
4848

4949
esdtValuesNum, err := dtb.balanceConverter.ComputeSliceOfStringsAsFloat(res.ESDTValues)
5050
if err != nil {
5151
log.Warn("dbTransactionBuilder.prepareTransaction: cannot compute esdt values as num",
52-
"esdt values", res.ESDTValues, "hash", txHash, "error", err)
52+
"esdt values", res.ESDTValues, "hash", txHashHex, "error", err)
5353
}
5454

5555
var esdtValues []string
@@ -66,7 +66,7 @@ func (dtb *dbTransactionBuilder) prepareUnexecutableTransaction(txHash []byte, t
6666
}
6767

6868
return &data.Transaction{
69-
Hash: hex.EncodeToString(txHash),
69+
Hash: txHashHex,
7070
Nonce: tx.Nonce,
7171
Round: headerData.Round,
7272
Value: tx.Value.String(),

process/elasticproc/transactions/transactionDBBuilder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func TestPrepareUnexecutableTransaction(t *testing.T) {
336336
require.Nil(t, err)
337337

338338
expectedTx := &data.Transaction{
339-
Hash: hex.EncodeToString(txHash),
339+
Hash: string(txHash),
340340
Nonce: tx.Nonce,
341341
Round: headerData.Round,
342342
Value: tx.Value.String(),
@@ -358,7 +358,7 @@ func TestPrepareUnexecutableTransaction(t *testing.T) {
358358
SenderShard: uint32(2),
359359
}
360360

361-
dbTx := cp.prepareUnexecutableTransaction(txHash, tx, headerData)
361+
dbTx := cp.prepareUnexecutableTransaction(string(txHash), tx, headerData)
362362
dbTx.UUID = ""
363363

364364
require.Equal(t, expectedTx, dbTx)

process/elasticproc/transactions/transactionsProcessor.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,13 @@ func (tdp *txsDatabaseProcessor) PrepareTransactionsForDatabase(
117117
}
118118
}
119119

120-
for hash, tx := range pool.UnexecutableTransactions {
121-
normalTxs[hex.EncodeToString([]byte(hash))] = tdp.txBuilder.prepareUnexecutableTransaction([]byte(hash), tx, headerData)
120+
for hashHex, tx := range pool.UnexecutableTransactions {
121+
decodedHash, errD := hex.DecodeString(hashHex)
122+
if errD != nil {
123+
continue
124+
}
125+
126+
normalTxs[string(decodedHash)] = tdp.txBuilder.prepareUnexecutableTransaction(hashHex, tx, headerData)
122127
}
123128

124129
normalTxs = tdp.setTransactionSearchOrder(normalTxs)

0 commit comments

Comments
 (0)