mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-12 14:42:38 +02:00
watchtower/wtdb: add encode/decode to session info + updates
This commit is contained in:
@@ -2,6 +2,7 @@ package wtdb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/lightningnetwork/lnd/watchtower/wtpolicy"
|
||||
)
|
||||
@@ -59,6 +60,28 @@ type SessionInfo struct {
|
||||
// TODO(conner): store client metrics, DOS score, etc
|
||||
}
|
||||
|
||||
// Encode serializes the session info to the given io.Writer.
|
||||
func (s *SessionInfo) Encode(w io.Writer) error {
|
||||
return WriteElements(w,
|
||||
s.ID,
|
||||
s.Policy,
|
||||
s.LastApplied,
|
||||
s.ClientLastApplied,
|
||||
s.RewardAddress,
|
||||
)
|
||||
}
|
||||
|
||||
// Decode deserializes the session infor from the given io.Reader.
|
||||
func (s *SessionInfo) Decode(r io.Reader) error {
|
||||
return ReadElements(r,
|
||||
&s.ID,
|
||||
&s.Policy,
|
||||
&s.LastApplied,
|
||||
&s.ClientLastApplied,
|
||||
&s.RewardAddress,
|
||||
)
|
||||
}
|
||||
|
||||
// AcceptUpdateSequence validates that a state update's sequence number and last
|
||||
// applied are valid given our past history with the client. These checks ensure
|
||||
// that clients are properly in sync and following the update protocol properly.
|
||||
|
Reference in New Issue
Block a user