Skip to content

Commit

Permalink
fixes after review: refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd04 committed Dec 18, 2023
1 parent 77fb490 commit 0d71a6c
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions process/preprocess/eventsPreProcessorV0.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,15 @@ func (d *eventsPreProcessorV0) parseTransactionsPool(txsPool *data.TransactionsP
return nil, process.ErrNilTransactionsPool
}

txs := make(map[string]*outport.TxInfo)
if txsPool.Txs != nil {
txs = d.parseTxs(txsPool.Txs)
}

scrs := make(map[string]*outport.SCRInfo)
if txsPool.Scrs != nil {
scrs = d.parseScrs(txsPool.Scrs)
}

logs := make([]*outport.LogData, 0)
if txsPool.Logs != nil {
logs = d.parseLogs(txsPool.Logs)
}

return &outport.TransactionPool{
Transactions: txs,
SmartContractResults: scrs,
Logs: logs,
Transactions: d.parseTxs(txsPool.Txs),
SmartContractResults: d.parseScrs(txsPool.Scrs),
Logs: d.parseLogs(txsPool.Logs),
}, nil
}

func (d *eventsPreProcessorV0) parseTxs(txs map[string]*data.NodeTransaction) map[string]*outport.TxInfo {
newTxs := make(map[string]*outport.TxInfo, len(txs))

newTxs := make(map[string]*outport.TxInfo)
for hash, txHandler := range txs {
if txHandler == nil {
continue
Expand All @@ -113,8 +97,7 @@ func (d *eventsPreProcessorV0) parseTxs(txs map[string]*data.NodeTransaction) ma
}

func (d *eventsPreProcessorV0) parseScrs(scrs map[string]*data.NodeSmartContractResult) map[string]*outport.SCRInfo {
newScrs := make(map[string]*outport.SCRInfo, len(scrs))

newScrs := make(map[string]*outport.SCRInfo)
for hash, scrHandler := range scrs {
if scrHandler == nil {
continue
Expand All @@ -132,7 +115,6 @@ func (d *eventsPreProcessorV0) parseScrs(scrs map[string]*data.NodeSmartContract

func (d *eventsPreProcessorV0) parseLogs(logs []*data.LogData) []*outport.LogData {
newLogs := make([]*outport.LogData, len(logs))

for _, logHandler := range logs {
if logHandler == nil {
continue
Expand Down

0 comments on commit 0d71a6c

Please sign in to comment.