diff --git a/store/iavl/store.go b/store/iavl/store.go index 77f611380535..28e7f68df7d1 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -223,7 +223,9 @@ func (st *Store) Has(key []byte) (exists bool) { // Implements types.KVStore. func (st *Store) Delete(key []byte) { defer telemetry.MeasureSince(time.Now(), "store", "iavl", "delete") - st.tree.Remove(key) + if _, _, err := st.tree.Remove(key); err != nil { + panic(err) + } } // DeleteVersions deletes a series of versions from the MutableTree. An error @@ -370,7 +372,8 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { for ; iterator.Valid(); iterator.Next() { pairs.Pairs = append(pairs.Pairs, kv.Pair{Key: iterator.Key(), Value: iterator.Value()}) } - iterator.Close() + + _ = iterator.Close() bz, err := pairs.Marshal() if err != nil { diff --git a/store/listenkv/store.go b/store/listenkv/store.go index 4595d0fe56d1..2ea0e9974c2a 100644 --- a/store/listenkv/store.go +++ b/store/listenkv/store.go @@ -144,6 +144,8 @@ func (s *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.Cach // onWrite writes a KVStore operation to all of the WriteListeners func (s *Store) onWrite(delete bool, key, value []byte) { for _, l := range s.listeners { - l.OnWrite(s.parentStoreKey, key, value, delete) + if err := l.OnWrite(s.parentStoreKey, key, value, delete); err != nil { + panic(err) + } } } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 79865502a33c..bebd6cd1af9a 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -312,7 +312,7 @@ func deleteKVStore(kv types.KVStore) error { keys = append(keys, itr.Key()) itr.Next() } - itr.Close() + _ = itr.Close() for _, k := range keys { kv.Delete(k) @@ -328,7 +328,7 @@ func moveKVStoreData(oldDB types.KVStore, newDB types.KVStore) error { newDB.Set(itr.Key(), itr.Value()) itr.Next() } - itr.Close() + _ = itr.Close() // then delete the old store return deleteKVStore(oldDB) @@ -1068,7 +1068,9 @@ func (rs *Store) GetCommitInfo(ver int64) (*types.CommitInfo, error) { func (rs *Store) flushMetadata(db dbm.DB, version int64, cInfo *types.CommitInfo) { rs.logger.Debug("flushing metadata", "height", version) batch := db.NewBatch() - defer batch.Close() + defer func() { + _ = batch.Close() + }() if cInfo != nil { flushCommitInfo(batch, version, cInfo) @@ -1168,7 +1170,10 @@ func flushCommitInfo(batch dbm.Batch, version int64, cInfo *types.CommitInfo) { } cInfoKey := fmt.Sprintf(commitInfoKeyFmt, version) - batch.Set([]byte(cInfoKey), bz) + + if err := batch.Set([]byte(cInfoKey), bz); err != nil { + panic(err) + } } func flushLatestVersion(batch dbm.Batch, version int64) { @@ -1177,5 +1182,7 @@ func flushLatestVersion(batch dbm.Batch, version int64) { panic(err) } - batch.Set([]byte(latestVersionKey), bz) + if err := batch.Set([]byte(latestVersionKey), bz); err != nil { + panic(err) + } } diff --git a/store/streaming/constructor.go b/store/streaming/constructor.go index b1b822bfa8fa..6693c938cdbb 100644 --- a/store/streaming/constructor.go +++ b/store/streaming/constructor.go @@ -163,7 +163,7 @@ func LoadStreamingServices( // Close any services we may have already spun up before hitting the error // on this one. for _, activeStreamer := range activeStreamers { - activeStreamer.Close() + _ = activeStreamer.Close() } return nil, nil, err @@ -176,7 +176,7 @@ func LoadStreamingServices( // Close any services we may have already spun up before hitting the error // on this one. for _, activeStreamer := range activeStreamers { - activeStreamer.Close() + _ = activeStreamer.Close() } return nil, nil, err @@ -186,7 +186,9 @@ func LoadStreamingServices( bApp.SetStreamingService(streamingService) // kick off the background streaming service loop - streamingService.Stream(wg) + if err := streamingService.Stream(wg); err != nil { + return nil, nil, err + } // add to the list of active streamers activeStreamers = append(activeStreamers, streamingService) diff --git a/store/tracekv/store.go b/store/tracekv/store.go index caf871552f56..d9c637823058 100644 --- a/store/tracekv/store.go +++ b/store/tracekv/store.go @@ -195,5 +195,7 @@ func writeOperation(w io.Writer, op operation, tc types.TraceContext, key, value panic(errors.Wrap(err, "failed to write trace operation")) } - io.WriteString(w, "\n") + if _, err = io.WriteString(w, "\n"); err != nil { + panic(errors.Wrap(err, "failed to write newline")) + } }