Skip to content
Snippets Groups Projects
Commit 6e832402 authored by Jake Taylor's avatar Jake Taylor
Browse files

Merge branch 'Optimus/ClientStorage' into XX-2415/NodeKeys

# Conflicts:
#	storage/session.go
parents a0f024eb b4f4d3c7
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@ import (
"gitlab.com/elixxir/primitives/switchboard"
"gitlab.com/xx_network/comms/connect"
goio "io"
"path/filepath"
"strings"
"testing"
"time"
......@@ -164,7 +165,8 @@ func (cl *Client) Login(password string) (*id.ID, error) {
// TODO: FIX ME
// While the old session is still valid, we are using the LocA storage to initialize the session
locA, _ := cl.storage.GetLocation()
io.SessionV2, err = storage.Init(locA, password)
dirname := filepath.Dir(locA)
io.SessionV2, err = storage.Init(dirname, password)
if err != nil {
return nil, errors.Wrap(err, "Login: could not initialize v2 storage")
}
......
......@@ -10,6 +10,8 @@ package api
import (
"fmt"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/io"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/comms/gateway"
pb "gitlab.com/elixxir/comms/mixmessages"
......@@ -58,6 +60,7 @@ func TestMain(m *testing.M) {
// Set logging params
jww.SetLogThreshold(jww.LevelTrace)
jww.SetStdoutThreshold(jww.LevelTrace)
io.SessionV2, _ = storage.Init(".ekvapi", "test")
os.Exit(testMainWrapper(m))
}
......
......@@ -15,7 +15,9 @@ import (
"fmt"
"gitlab.com/elixxir/client/cmixproto"
"gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/io"
"gitlab.com/elixxir/client/parse"
"gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/comms/gateway"
pb "gitlab.com/elixxir/comms/mixmessages"
......@@ -81,6 +83,7 @@ func (i *MockRegistration) CheckRegistration(msg *pb.RegisteredNodeCheck) (*pb.R
// Setups general testing params and calls test wrapper
func TestMain(m *testing.M) {
io.SessionV2, _ = storage.Init(".ekvbindings", "test")
os.Exit(testMainWrapper(m))
}
......
......@@ -17,10 +17,11 @@ require (
github.com/spf13/viper v1.6.2
gitlab.com/elixxir/comms v0.0.0-20200803223713-26b69d6adff9
gitlab.com/elixxir/crypto v0.0.0-20200803223738-661ca14b6470
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842
gitlab.com/elixxir/ekv v0.1.0
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d
gitlab.com/xx_network/comms v0.0.0-20200803203304-a7a1c5e4239d
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect
gopkg.in/ini.v1 v1.52.0 // indirect
)
......
......@@ -172,6 +172,8 @@ gitlab.com/elixxir/crypto v0.0.0-20200803223738-661ca14b6470 h1:WGECBA9PtyUk9Rfk
gitlab.com/elixxir/crypto v0.0.0-20200803223738-661ca14b6470/go.mod h1:LHBAaEf48a0/AjU118rjoworH0LgXifhAqmNX3ZRvME=
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842 h1:m1zDQ6UadpuMnV7nvnyR+DUXE3AisRnVjajTb1xZE4c=
gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s=
gitlab.com/elixxir/ekv v0.1.0 h1:CXYdlWzR2MmT54WaVw3REdWayuSxYuGOQoAHL2YTWTA=
gitlab.com/elixxir/ekv v0.1.0/go.mod h1:bXY0kgbV5BHYda4YY5/hiG5bjimGK+R3PYub5yM9C/s=
gitlab.com/elixxir/primitives v0.0.0-20200706165052-9fe7a4fb99a3 h1:GTfflZBNLeBq3UApYog0J3+hytdkoRsDduGQji2wyEU=
gitlab.com/elixxir/primitives v0.0.0-20200706165052-9fe7a4fb99a3/go.mod h1:OQgUZq7SjnE0b+8+iIAT2eqQF+2IFHn73tOo+aV11mg=
gitlab.com/elixxir/primitives v0.0.0-20200731184040-494269b53b4d h1:OKWTmYN5q8XVHo8JXThIH0TCuvl/fLXR7MGVacpqfRg=
......@@ -195,6 +197,8 @@ golang.org/x/crypto v0.0.0-20200707235045-ab33eee955e0 h1:eIYIE7EC5/Wv5Kbz8bJPaq
golang.org/x/crypto v0.0.0-20200707235045-ab33eee955e0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 h1:DZhuSZLsGlFL4CmhA8BcRA0mnthyA/nZ00AqCUo7vHg=
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
......@@ -225,6 +229,8 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 h1:B6caxRw+hozq68X2MY7jEpZh/cr4/aHLv9xU8Kkadrw=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
......
......@@ -174,8 +174,15 @@ func (rm *ReceptionManager) receiveMessagesFromGateway(session user.Session,
pollingMessage *pb.ClientRequest, receiveGateway *connect.Host) ([]*format.Message, error) {
// Get the last message ID received
var err error
// FIXME: Cleanup after user.Session is removed and replaced.
if SessionV2 == nil {
globals.Log.WARN.Printf("SessionV2 is nil")
return nil, errors.New("SessionV2 is nil")
}
pollingMessage.LastMessageID, err = SessionV2.GetLastMessageId()
if err != nil {
globals.Log.WARN.Printf("Could not get LastMessageID: %+v", err)
return nil, err
}
// FIXME: dont do this over an over
......
......@@ -4,6 +4,8 @@
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
// Session object definition
package storage
import (
......@@ -15,10 +17,12 @@ import (
"time"
)
// Session object, backed by encrypted filestore
type Session struct {
kv *VersionedKV
}
// Initialize a new Session object
func Init(baseDir, password string) (*Session, error) {
fs, err := ekv.NewFilestore(baseDir, password)
var s *Session
......@@ -31,10 +35,12 @@ func Init(baseDir, password string) (*Session, error) {
return s, err
}
// Get an object from the session
func (s *Session) Get(key string) (*VersionedObject, error) {
return s.kv.Get(key)
}
// Set a value in the session
func (s *Session) Set(key string, object *VersionedObject) error {
return s.kv.Set(key, object)
}
......@@ -42,8 +48,8 @@ func (s *Session) Set(key string, object *VersionedObject) error {
// Obtain the LastMessageID from the Session
func (s *Session) GetLastMessageId() (string, error) {
v, err := s.kv.Get("LastMessageID")
if err != nil {
return "", err
if v == nil || err != nil {
return "", nil
}
return string(v.Data), nil
}
......
......@@ -113,6 +113,11 @@ func (v *VersionedKV) Get(key string) (*VersionedObject, error) {
return &result, nil
}
// Delete removes a given key from the data store
func (v *VersionedKV) Delete(key string) error {
return v.data.Delete(key)
}
// Set upserts new data into the storage
// When calling this, you are responsible for prefixing the key with the correct
// type and version! Call MakeKeyPrefix() to do so.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment