[client.keyset] added 'consumption level' in Store/Fetch mecanism

This commit is contained in:
xdrm-brackets 2018-04-21 17:18:49 +02:00
parent d0225993fe
commit c9828e9807
1 changed files with 18 additions and 1 deletions

View File

@ -19,7 +19,7 @@ type Set struct {
max uint16 // max depth max uint16 // max depth
sec []byte // secret sec []byte // secret
consumption uint // consumption level consumption uint8 // consumption level
// 0: none // 0: none
// 1: need to migrate // 1: need to migrate
// 2: waiting migration // 2: waiting migration
@ -123,6 +123,15 @@ func (s *Set) Decrement() uint16 {
} }
/* (5) Prepare a renewal
*
* @return level<outType> outDesc
*
---------------------------------------------------------*/
/* (5) Serialisation /* (5) Serialisation
* *
* @return serial<string> String representation * @return serial<string> String representation
@ -155,6 +164,10 @@ func (s *Set) Store(writer io.Writer) error {
err = binary.Write(writer, binary.BigEndian, s.depth) err = binary.Write(writer, binary.BigEndian, s.depth)
if err != nil { return err } if err != nil { return err }
/* (4) Copy migration level */
err = binary.Write(writer, binary.BigEndian, s.consumption)
if err != nil { return err }
return nil return nil
} }
@ -200,6 +213,10 @@ func (s *Set) Fetch(reader io.Reader) error {
err = binary.Read(reader, binary.BigEndian, &s.depth) err = binary.Read(reader, binary.BigEndian, &s.depth)
if err != nil { return err } 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 return nil
} }