From 47bac19b9e77726d5168f76c191eafc19c6a535e Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Mon, 17 Jun 2024 10:28:07 -0400 Subject: [PATCH] update slice encoding --- go.mod | 3 ++- persist/sqlite/encoding.go | 10 ++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 90e4aefa..7fdffb00 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module go.sia.tech/explored -go 1.21.6 +go 1.21.8 + toolchain go1.22.4 require ( diff --git a/persist/sqlite/encoding.go b/persist/sqlite/encoding.go index 7b425e6c..3e578880 100644 --- a/persist/sqlite/encoding.go +++ b/persist/sqlite/encoding.go @@ -28,10 +28,7 @@ func encode(obj any) any { case []types.Hash256: var buf bytes.Buffer e := types.NewEncoder(&buf) - e.WritePrefix(len(obj)) - for _, o := range obj { - o.EncodeTo(e) - } + types.EncodeSlice(e, obj) e.Flush() return buf.Bytes() case uint64: @@ -70,10 +67,7 @@ func (d *decodable) Scan(src any) error { return dec.Err() case *[]types.Hash256: dec := types.NewBufDecoder(src) - *v = make([]types.Hash256, dec.ReadPrefix()) - for i := range *v { - (*v)[i].DecodeFrom(dec) - } + types.DecodeSlice(dec, v) return dec.Err() case *uint64: *v = binary.BigEndian.Uint64(src)