Skip to content

Commit

Permalink
Cleanup from Simon's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Apr 28, 2022
1 parent a154a9a commit 3e512fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x/wasm/ioutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"compress/gzip"
)

var (
const (
// magic bytes to identify gzip.
// See https://www.ietf.org/rfc/rfc1952.txt
// and https://github.com/golang/go/blob/master/src/net/http/sniff.go#L186
Expand Down
8 changes: 4 additions & 4 deletions x/wasm/keeper/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ func (ws *WasmSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) e
cacheMS := ws.cms.CacheMultiStore()

ctx := sdk.NewContext(cacheMS, tmproto.Header{}, false, log.NewNopLogger())
uniqueHashes := make(map[string]bool)
seenBefore := make(map[string]bool)
var rerr error

ws.wasm.IterateCodeInfos(ctx, func(id uint64, info types.CodeInfo) bool {
// Many code ids may point to the same code hash... only sync it once
hexHash := hex.EncodeToString(info.CodeHash)
// if uniqueHashes, just skip this one and move to the next
if uniqueHashes[hexHash] {
// if seenBefore, just skip this one and move to the next
if seenBefore[hexHash] {
return false
}
uniqueHashes[hexHash] = true
seenBefore[hexHash] = true

// load code and abort on error
wasmBytes, err := ws.wasm.GetByteCode(ctx, id)
Expand Down

0 comments on commit 3e512fd

Please sign in to comment.