From 0d9107a098230de7138abb1c201877c246e89ed1 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 13 Feb 2019 12:28:42 +0400 Subject: [PATCH] rewrite indexer service in the attempt to fix failing test https://github.com/tendermint/tendermint/pull/3227/#issuecomment-462316527 --- state/txindex/indexer_service.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/state/txindex/indexer_service.go b/state/txindex/indexer_service.go index 7ecfeff17..c6ac839dd 100644 --- a/state/txindex/indexer_service.go +++ b/state/txindex/indexer_service.go @@ -46,8 +46,13 @@ func (is *IndexerService) OnStart() error { select { case msg := <-blockHeadersSub.Out(): header := msg.Data().(types.EventDataNewBlockHeader).Header + if header.NumTxs == 0 { + continue + } batch := NewBatch(header.NumTxs) - for i := int64(0); i < header.NumTxs; i++ { + i := int64(0) + TXS_LOOP: + for { select { case msg2 := <-txsSub.Out(): txResult := msg2.Data().(types.EventDataTx).TxResult @@ -57,6 +62,10 @@ func (is *IndexerService) OnStart() error { "index", txResult.Index, "err", err) } + i++ + if i == header.NumTxs { + break TXS_LOOP + } case <-txsSub.Cancelled(): is.Logger.Error("Failed to index block. txsSub was cancelled. Did the Tendermint stop?", "height", header.Height,