watchtower/wtdb: add encode/decode to session info + updates
This commit is contained in:
2 files changed
+47
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package wtdb
|
||||
|
||||
import "io"
|
||||
|
||||
// SessionStateUpdate holds a state update sent by a client along with its
|
||||
// SessionID.
|
||||
type SessionStateUpdate struct {
|
||||
@@ -21,3 +23,25 @@ type SessionStateUpdate struct {
|
||||
// hint is braodcast.
|
||||
EncryptedBlob []byte
|
||||
}
|
||||
|
||||
// Encode serializes the state update into the provided io.Writer.
|
||||
func (u *SessionStateUpdate) Encode(w io.Writer) error {
|
||||
return WriteElements(w,
|
||||
u.ID,
|
||||
u.SeqNum,
|
||||
u.LastApplied,
|
||||
u.Hint,
|
||||
u.EncryptedBlob,
|
||||
)
|
||||
}
|
||||
|
||||
// Decode deserializes the target state update from the provided io.Reader.
|
||||
func (u *SessionStateUpdate) Decode(r io.Reader) error {
|
||||
return ReadElements(r,
|
||||
&u.ID,
|
||||
&u.SeqNum,
|
||||
&u.LastApplied,
|
||||
&u.Hint,
|
||||
&u.EncryptedBlob,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user