Skip to content

Commit

Permalink
respond to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Sep 3, 2024
1 parent 126621c commit d4e7107
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions lib/runtime/wazero/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -2124,30 +2124,35 @@ func ext_storage_clear_prefix_version_2(ctx context.Context, m api.Module, prefi
limitPtr = &maxLimit
}

if !bytes.HasPrefix(prefix, childStorageKeyPrefix) {
numRemoved, all, err := storage.ClearPrefixLimit(prefix, *limitPtr)
if bytes.HasPrefix(prefix, childStorageKeyPrefix) {
logger.Warnf("cannot clear child prefix: 0x%x", prefix)
encBytes, err := toKillStorageResultEnum(false, 0)
if err != nil {
logger.Errorf("failed to clear prefix limit: %s", err)
panic(err)
}

encBytes, err := toKillStorageResultEnum(all, numRemoved)
if err != nil {
logger.Errorf("failed to allocate memory: %s", err)
panic(err)
}
valueSpan := mustWrite(m, rtCtx.Allocator, encBytes)
return valueSpan
}

valueSpan, err := write(m, rtCtx.Allocator, encBytes)
if err != nil {
logger.Errorf("failed to allocate: %s", err)
panic(err)
}
numRemoved, all, err := storage.ClearPrefixLimit(prefix, *limitPtr)
if err != nil {
logger.Errorf("failed to clear prefix limit: %s", err)
panic(err)
}

return valueSpan
} else {
logger.Warnf("cannot clear prefix that is part of or contains a child storage key")
encBytes, err := toKillStorageResultEnum(all, numRemoved)
if err != nil {
logger.Errorf("failed to allocate memory: %s", err)
panic(err)
}
return 0

valueSpan, err := write(m, rtCtx.Allocator, encBytes)
if err != nil {
logger.Errorf("failed to allocate: %s", err)
panic(err)
}
return valueSpan
}

func ext_storage_exists_version_1(ctx context.Context, m api.Module, keySpan uint64) uint32 {
Expand Down

0 comments on commit d4e7107

Please sign in to comment.