Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
dc6e3f15
Commit
dc6e3f15
authored
Aug 7, 2020
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
switch to gob encoding
parent
7d25a8b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/session.go
+20
-11
20 additions, 11 deletions
storage/session.go
user/session.go
+2
-2
2 additions, 2 deletions
user/session.go
with
22 additions
and
13 deletions
storage/session.go
+
20
−
11
View file @
dc6e3f15
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
package
storage
package
storage
import
(
import
(
"encoding/json"
"bytes"
"encoding/gob"
"gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/globals"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/ekv"
...
@@ -83,14 +84,19 @@ func (s *Session) getNodeKeys() (map[string]user.NodeKeys, error) {
...
@@ -83,14 +84,19 @@ func (s *Session) getNodeKeys() (map[string]user.NodeKeys, error) {
return
nil
,
err
return
nil
,
err
}
}
// Encode the new map
nodeKeys
=
make
(
map
[
string
]
user
.
NodeKeys
)
nodeKeys
=
make
(
map
[
string
]
user
.
NodeKeys
)
data
,
err
:=
json
.
Marshal
(
nodeKeys
)
var
nodeKeysBuffer
bytes
.
Buffer
enc
:=
gob
.
NewEncoder
(
&
nodeKeysBuffer
)
err
=
enc
.
Encode
(
nodeKeys
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
// Store the new map
vo
:=
&
VersionedObject
{
vo
:=
&
VersionedObject
{
Timestamp
:
ts
,
Timestamp
:
ts
,
Data
:
data
,
Data
:
nodeKeysBuffer
.
Bytes
()
,
}
}
err
=
s
.
kv
.
Set
(
key
,
vo
)
err
=
s
.
kv
.
Set
(
key
,
vo
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -101,8 +107,12 @@ func (s *Session) getNodeKeys() (map[string]user.NodeKeys, error) {
...
@@ -101,8 +107,12 @@ func (s *Session) getNodeKeys() (map[string]user.NodeKeys, error) {
return
nodeKeys
,
nil
return
nodeKeys
,
nil
}
}
// If the map exists, return it
// If the map exists, decode and return it
err
=
json
.
Unmarshal
(
v
.
Data
,
&
nodeKeys
)
var
nodeKeyBuffer
bytes
.
Buffer
nodeKeyBuffer
.
Write
(
v
.
Data
)
dec
:=
gob
.
NewDecoder
(
&
nodeKeyBuffer
)
err
=
dec
.
Decode
(
&
nodeKeys
)
return
nodeKeys
,
err
return
nodeKeys
,
err
}
}
...
@@ -133,11 +143,10 @@ func (s *Session) PushNodeKey(id *id.ID, key user.NodeKeys) error {
...
@@ -133,11 +143,10 @@ func (s *Session) PushNodeKey(id *id.ID, key user.NodeKeys) error {
// Set new value inside of map
// Set new value inside of map
nodeKeys
[
id
.
String
()]
=
key
nodeKeys
[
id
.
String
()]
=
key
// Marshal the map
// Encode the map
pushValue
,
err
:=
json
.
Marshal
(
nodeKeys
)
var
nodeKeysBuffer
bytes
.
Buffer
if
err
!=
nil
{
enc
:=
gob
.
NewEncoder
(
&
nodeKeysBuffer
)
return
err
err
=
enc
.
Encode
(
nodeKeys
)
}
// Insert the map back into the Session
// Insert the map back into the Session
ts
,
err
:=
time
.
Now
()
.
MarshalText
()
ts
,
err
:=
time
.
Now
()
.
MarshalText
()
...
@@ -146,7 +155,7 @@ func (s *Session) PushNodeKey(id *id.ID, key user.NodeKeys) error {
...
@@ -146,7 +155,7 @@ func (s *Session) PushNodeKey(id *id.ID, key user.NodeKeys) error {
}
}
vo
:=
&
VersionedObject
{
vo
:=
&
VersionedObject
{
Timestamp
:
ts
,
Timestamp
:
ts
,
Data
:
pushValue
,
Data
:
nodeKeysBuffer
.
Bytes
()
,
}
}
return
s
.
kv
.
Set
(
"NodeKeys"
,
vo
)
return
s
.
kv
.
Set
(
"NodeKeys"
,
vo
)
}
}
...
...
This diff is collapsed.
Click to expand it.
user/session.go
+
2
−
2
View file @
dc6e3f15
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Copyright © 20
19
Privategrity Corporation /
// Copyright © 20
20
Privategrity Corporation /
// /
// /
// All rights reserved. /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
...
@@ -142,7 +142,7 @@ func LoadSession(store globals.Storage, password string) (Session, error) {
...
@@ -142,7 +142,7 @@ func LoadSession(store globals.Storage, password string) (Session, error) {
}
}
}
}
//extract t
e
h session from the wrapper
//extract th
e
session from the wrapper
var
sessionBytes
bytes
.
Buffer
var
sessionBytes
bytes
.
Buffer
sessionBytes
.
Write
(
wrappedSession
.
Session
)
sessionBytes
.
Write
(
wrappedSession
.
Session
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment