From 89f6338cc919b52e55300fab227690d0e344a82e Mon Sep 17 00:00:00 2001 From: Rado M Date: Thu, 31 Aug 2023 15:51:30 +0300 Subject: [PATCH] fix reaching the max alloc size with the custom gc --- fixed_length.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fixed_length.go b/fixed_length.go index 354f502..b69be2b 100644 --- a/fixed_length.go +++ b/fixed_length.go @@ -14,12 +14,15 @@ import ( ) func (value U8) Encode(buffer *bytes.Buffer) { + // do not use value.Bytes() here: https://github.com/LimeChain/goscale/issues/77 encoder := Encoder{Writer: buffer} - encoder.Write(value.Bytes()) + encoder.EncodeByte(byte(value)) } func (value U8) Bytes() []byte { - return []byte{byte(value)} + buf := make([]byte, 1) + buf[0] = byte(value) + return buf } func DecodeU8(buffer *bytes.Buffer) U8 {