From 1892ba62cd5c5c9bb7d016ccd15efbc416eee001 Mon Sep 17 00:00:00 2001 From: yzang2019 Date: Wed, 6 Sep 2023 22:27:29 -0700 Subject: [PATCH] Add close for cacheCMS --- x/wasm/keeper/snapshotter.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/wasm/keeper/snapshotter.go b/x/wasm/keeper/snapshotter.go index a781cb0..2b7a01b 100644 --- a/x/wasm/keeper/snapshotter.go +++ b/x/wasm/keeper/snapshotter.go @@ -50,7 +50,12 @@ func (ws *WasmSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) e if err != nil { return err } - + defer func() { + // We should close the multistore to avoid leaking resources. + if closer, ok := cacheMS.(io.Closer); ok { + _ = closer.Close() + } + }() ctx := sdk.NewContext(cacheMS, tmproto.Header{}, false, log.NewNopLogger()) seenBefore := make(map[string]bool) var rerr error