From 6628f924ba4aefa8f8361ebc252fb225718359c2 Mon Sep 17 00:00:00 2001 From: bt Date: Thu, 4 Jun 2026 17:13:39 +0200 Subject: [common] Add channels list query --- core/payload.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'core/payload.go') diff --git a/core/payload.go b/core/payload.go index be9d844..aad21ee 100644 --- a/core/payload.go +++ b/core/payload.go @@ -226,6 +226,55 @@ func DecodeHistory(buf io.Reader) (History, error) { return h, nil } +type List struct { + Count int64 + Offset int64 +} + +func (l List) Wrap() (PayloadType, []any) { + return PayloadList, []any{ + l.Count, + l.Offset, + } +} + +func DecodeList(buf io.Reader) (List, error) { + var l List + + err := decodeNumeric(buf, &l.Count) + if err != nil { + return l, err + } + + err = decodeNumeric(buf, &l.Offset) + if err != nil { + return l, err + } + + return l, nil +} + +type ListItem struct { + Address string +} + +func (l ListItem) Wrap() (PayloadType, []any) { + return PayloadListItem, []any{ + l.Address, + } +} + +func DecodeListItem(buf io.Reader) (ListItem, error) { + var l ListItem + + err := decodeString(buf, &l.Address) + if err != nil { + return l, err + } + + return l, nil +} + type Test struct { Num1 uint8 Time1 time.Time -- cgit v1.2.3