Skip to content

Commit a8d025b

Browse files
committed
Add goroutine
1 parent f50175a commit a8d025b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

internal/state/indexer/indexer_service.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,21 @@ func (is *Service) publish(msg pubsub.Message) error {
9595
}
9696

9797
if curr.Size() != 0 {
98-
start := time.Now()
99-
err := sink.IndexTxEvents(curr.Ops)
100-
if err != nil {
101-
is.logger.Error("failed to index block txs",
102-
"height", is.currentBlock.height, "err", err)
103-
} else {
104-
is.metrics.TxEventsSeconds.Observe(time.Since(start).Seconds())
105-
is.metrics.TransactionsIndexed.Add(float64(curr.Size()))
106-
is.logger.Debug("indexed txs",
107-
"height", is.currentBlock.height, "sink", sink.Type())
108-
}
98+
go func() {
99+
ops := curr.Ops
100+
start := time.Now()
101+
err := sink.IndexTxEvents(ops)
102+
if err != nil {
103+
is.logger.Error("failed to index block txs",
104+
"height", is.currentBlock.height, "err", err)
105+
} else {
106+
is.metrics.TxEventsSeconds.Observe(time.Since(start).Seconds())
107+
is.metrics.TransactionsIndexed.Add(float64(curr.Size()))
108+
is.logger.Debug("indexed txs",
109+
"height", is.currentBlock.height, "sink", sink.Type())
110+
}
111+
}()
112+
109113
}
110114
}
111115
is.currentBlock.batch = nil // return to the WAIT state for the next block

0 commit comments

Comments
 (0)