summaryrefslogtreecommitdiffstats
path: root/core/payload.go
diff options
context:
space:
mode:
authorbt <bt@rctt.net>2026-05-16 19:15:21 +0200
committerbt <bt@rctt.net>2026-05-16 22:46:48 +0200
commit82902e9dc3ad67c49e4f9381b83d38a659efa083 (patch)
treee53faaa5231eb6624fea4e4c448709d7a8765d37 /core/payload.go
parentc04c73a4df223c8c2b2b42ed482fc0181948e6ea (diff)
downloadsolec-82902e9dc3ad67c49e4f9381b83d38a659efa083.tar.gz
solec-82902e9dc3ad67c49e4f9381b83d38a659efa083.zip
Add history reading
Diffstat (limited to 'core/payload.go')
-rw-r--r--core/payload.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/payload.go b/core/payload.go
index 3c3afa1..b54a8cd 100644
--- a/core/payload.go
+++ b/core/payload.go
@@ -185,6 +185,47 @@ func DecodeUsermode(buf io.Reader) (Usermode, error) {
return u, nil
}
+type History struct {
+ Channel string
+ Since time.Time
+ Count int64
+ Offset int64
+}
+
+func (h History) Wrap() (PayloadType, []any) {
+ return PayloadHistory, []any{
+ h.Channel,
+ h.Since,
+ h.Count,
+ h.Offset,
+ }
+}
+
+func DecodeHistory(buf io.Reader) (History, error) {
+ var h History
+ err := decodeString(buf, &h.Channel)
+ if err != nil {
+ return h, err
+ }
+
+ err = decodeTime(buf, &h.Since)
+ if err != nil {
+ return h, err
+ }
+
+ err = decodeNumeric(buf, &h.Count)
+ if err != nil {
+ return h, err
+ }
+
+ err = decodeNumeric(buf, &h.Offset)
+ if err != nil {
+ return h, err
+ }
+
+ return h, nil
+}
+
type Test struct {
Num1 uint8
Time1 time.Time