Skip to content

Commit

Permalink
update slice encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Jun 17, 2024
1 parent 3228ceb commit 47bac19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module go.sia.tech/explored

go 1.21.6
go 1.21.8

toolchain go1.22.4

require (
Expand Down
10 changes: 2 additions & 8 deletions persist/sqlite/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 47bac19

Please sign in to comment.