From 245475181230025ed23f727a6439e667dbb6e460 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 22 Apr 2018 01:19:42 +0200 Subject: [PATCH] [client:client] moved private methods into {client:client.internal} --- src/git.xdrm.io/schastsp/client/client.go | 64 ------------------ .../schastsp/client/client.internal.go | 65 +++++++++++++++++++ 2 files changed, 65 insertions(+), 64 deletions(-) create mode 100644 src/git.xdrm.io/schastsp/client/client.internal.go diff --git a/src/git.xdrm.io/schastsp/client/client.go b/src/git.xdrm.io/schastsp/client/client.go index 86ed78a..410d4a2 100644 --- a/src/git.xdrm.io/schastsp/client/client.go +++ b/src/git.xdrm.io/schastsp/client/client.go @@ -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") } - } \ No newline at end of file diff --git a/src/git.xdrm.io/schastsp/client/client.internal.go b/src/git.xdrm.io/schastsp/client/client.internal.go new file mode 100644 index 0000000..8a98f02 --- /dev/null +++ b/src/git.xdrm.io/schastsp/client/client.internal.go @@ -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") } + +} \ No newline at end of file