[client:client] moved private methods into {client:client.internal}

This commit is contained in:
xdrm-brackets 2018-04-22 01:19:42 +02:00
parent 046fed121a
commit 2454751812
2 changed files with 65 additions and 64 deletions

View File

@ -46,68 +46,4 @@ func New(ctx *context.T, saveDir string) (*T, error) {
return inst, nil;
}
/* (1) Updates 'key' and 'sync' with files (reads or write)
*
---------------------------------------------------------*/
func (c T) update(){
var err error;
/* (1) Restore if both are NIL
---------------------------------------------------------*/
if c.key == nil && c.sync == nil {
/* (1) Create default key */
c.key, err = keyset.Create(c.ctx);
/* (2) Fetch key */
err = c.fkey.Fetch(c.key)
/* (3) On error -> set key to NIL */
if err != nil { c.key = nil }
/* (4) Create default sync */
c.sync, err = keyset.Create(c.ctx);
/* (5) Fetch sync */
err = c.fsync.Fetch(c.sync)
/* (6) On error -> set sync to NIL */
if err != nil { c.sync = nil }
/* (7) Exit if all keysets have been fetched */
if c.key != nil && c.sync != nil {
return;
}
}
/* (2) If cannot fetch -> create new keysets
---------------------------------------------------------*/
if c.key == nil{
c.key, _ = keyset.Create(c.ctx);
}
if c.sync == nil{
c.sync, _ = keyset.Create(c.ctx);
}
/* (3) Store current value
---------------------------------------------------------*/
/* (1) Store key */
err = c.fkey.Store(c.key)
if err != nil { panic("Cannot store key") }
/* (2) Store sync */
err = c.fsync.Store(c.sync)
if err != nil { panic("Cannot store sync") }
}

View File

@ -0,0 +1,65 @@
package client;
import "git.xdrm.io/schastsp/client/keyset"
/* (1) Updates 'key' and 'sync' with files
*
---------------------------------------------------------*/
func (c T) update(){
var err error;
/* (1) Restore if both are NIL
---------------------------------------------------------*/
if c.key == nil && c.sync == nil {
/* (1) Create default key */
c.key, err = keyset.Create(c.ctx);
/* (2) Fetch key */
err = c.fkey.Fetch(c.key)
/* (3) On error -> set key to NIL */
if err != nil { c.key = nil }
/* (4) Create default sync */
c.sync, err = keyset.Create(c.ctx);
/* (5) Fetch sync */
err = c.fsync.Fetch(c.sync)
/* (6) On error -> set sync to NIL */
if err != nil { c.sync = nil }
/* (7) Exit if all keysets have been fetched */
if c.key != nil && c.sync != nil {
return;
}
}
/* (2) If cannot fetch -> create new keysets
---------------------------------------------------------*/
if c.key == nil{
c.key, _ = keyset.Create(c.ctx);
}
if c.sync == nil{
c.sync, _ = keyset.Create(c.ctx);
}
/* (3) Store current value
---------------------------------------------------------*/
/* (1) Store key */
err = c.fkey.Store(c.key)
if err != nil { panic("Cannot store key") }
/* (2) Store sync */
err = c.fsync.Store(c.sync)
if err != nil { panic("Cannot store sync") }
}