14 return "WASM code not compressed by zstd!";
16 return "Unknown error";
25 0x52, 0xBC, 0x53, 0x76, 0x46, 0xDB, 0x8E, 0x05};
32 if (buf.size() > kZstdPrefixSize
33 && std::equal(buf.begin(),
35 std::begin(kZstdPrefix),
36 std::end(kZstdPrefix))) {
40 auto check_size = ZSTD_getFrameContentSize(buf.data() +
kZstdPrefixSize,
42 if (check_size == ZSTD_CONTENTSIZE_ERROR) {
45 res.
resize(kCodeBlobBombLimit);
46 auto size = ZSTD_decompress(res.data(),
54 return outcome::success();
Class represents arbitrary (including empty) byte buffer.
constexpr size_t kCodeBlobBombLimit
SLBuffer & resize(size_t size)
constexpr uint8_t kZstdPrefixSize
OUTCOME_CPP_DEFINE_CATEGORY(kagome::runtime, UncompressError, e)
constexpr uint8_t kZstdPrefix[kZstdPrefixSize]
outcome::result< void > uncompressCodeIfNeeded(common::BufferView buf, common::Buffer &res)