[client.keyset] added 'consumption level' in Store/Fetch mecanism
This commit is contained in:
parent
d0225993fe
commit
c9828e9807
|
@ -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<outType> outDesc
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* (5) Serialisation
|
||||
*
|
||||
* @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)
|
||||
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
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue