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 cdcb18d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions x/wasm/ioutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"compress/gzip"
)

// Note: []byte can never be const as they are inherently mutable
var (
// magic bytes to identify gzip.
// See https://www.ietf.org/rfc/rfc1952.txt
Expand Down
10 changes: 5 additions & 5 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 Expand Up @@ -160,7 +160,7 @@ func (ws *WasmSnapshotter) processAllItems(
cb func(sdk.Context, *Keeper, []byte) error,
finalize func(sdk.Context, *Keeper) error,
) (snapshot.SnapshotItem, error) {
ctx := sdk.NewContext(ws.cms, tmproto.Header{}, false, log.NewNopLogger())
ctx := sdk.NewContext(ws.cms, tmproto.Header{Height: int64(height)}, false, log.NewNopLogger())

// keep the last item here... if we break, it will either be empty (if we hit io.EOF)
// or contain the last item (if we hit payload == nil)
Expand Down

0 comments on commit cdcb18d

Please sign in to comment.