From c9828e9807a27d0dc7fbc09266eac892b9404943 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 21 Apr 2018 17:18:49 +0200 Subject: [PATCH] [client.keyset] added 'consumption level' in Store/Fetch mecanism --- .../schastsp/client/keyset/keyset.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/git.xdrm.io/schastsp/client/keyset/keyset.go b/src/git.xdrm.io/schastsp/client/keyset/keyset.go index 0a44ac7..4cf6119 100644 --- a/src/git.xdrm.io/schastsp/client/keyset/keyset.go +++ b/src/git.xdrm.io/schastsp/client/keyset/keyset.go @@ -19,7 +19,7 @@ type Set struct { max uint16 // max depth sec []byte // secret - consumption uint // consumption level + consumption uint8 // consumption level // 0: none // 1: need to migrate // 2: waiting migration @@ -123,6 +123,15 @@ func (s *Set) Decrement() uint16 { } + +/* (5) Prepare a renewal +* +* @return level outDesc +* +---------------------------------------------------------*/ + + + /* (5) Serialisation * * @return serial String representation @@ -155,6 +164,10 @@ func (s *Set) Store(writer io.Writer) error { err = binary.Write(writer, binary.BigEndian, s.depth) if err != nil { return err } + /* (4) Copy migration level */ + err = binary.Write(writer, binary.BigEndian, s.consumption) + if err != nil { return err } + return nil } @@ -200,6 +213,10 @@ func (s *Set) Fetch(reader io.Reader) error { err = binary.Read(reader, binary.BigEndian, &s.depth) if err != nil { return err } + /* (6) Try to copy the consumption level */ + err = binary.Read(reader, binary.BigEndian, &s.consumption) + if err != nil { return err } + return nil }