diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 51b512f28..ce21dbac8 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -32,3 +32,4 @@ program](https://hackerone.com/tendermint). - [tools] [\#4023](https://github.com/tendermint/tendermint/issues/4023) Refresh `tm-monitor` health when validator count is updated (@erikgrinaker) - [state] [\#4104](https://github.com/tendermint/tendermint/pull/4104) txindex/kv: Fsync data to disk immediately after receiving it (@guagualvcha) +- [state] [\#4095](https://github.com/tendermint/tendermint/pull/4095) txindex/kv: Return an error if there's one when the user searches for a tx (hash=X) (@hsyis) diff --git a/state/txindex/kv/kv.go b/state/txindex/kv/kv.go index dd9c5f300..e6f0e67bf 100644 --- a/state/txindex/kv/kv.go +++ b/state/txindex/kv/kv.go @@ -179,10 +179,14 @@ func (txi *TxIndex) Search(q *query.Query) ([]*types.TxResult, error) { return nil, errors.Wrap(err, "error during searching for a hash in the query") } else if ok { res, err := txi.Get(hash) - if res == nil { + switch { + case err != nil: + return []*types.TxResult{}, errors.Wrap(err, "error while retrieving the result") + case res == nil: return []*types.TxResult{}, nil + default: + return []*types.TxResult{res}, nil } - return []*types.TxResult{res}, errors.Wrap(err, "error while retrieving the result") } // conditions to skip because they're handled before "everything else"