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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
6e267993
Commit
6e267993
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
made the key object the master of its storage
parent
da879941
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/cmix/key.go
+16
-5
16 additions, 5 deletions
storage/cmix/key.go
storage/cmix/store.go
+1
-2
1 addition, 2 deletions
storage/cmix/store.go
with
17 additions
and
7 deletions
storage/cmix/key.go
+
16
−
5
View file @
6e267993
...
...
@@ -10,7 +10,20 @@ import (
const
currentKeyVersion
=
0
type
key
struct
{
kv
*
versioned
.
KV
k
*
cyclic
.
Int
storeKey
string
}
func
NewKey
(
kv
*
versioned
.
KV
,
k
*
cyclic
.
Int
,
id
*
id
.
ID
)
(
*
key
,
error
)
{
newKey
:=
&
key
{
kv
:
kv
,
k
:
k
,
storeKey
:
keyKey
(
id
),
}
return
newKey
,
newKey
.
save
()
}
// loads the key for the given node id from the versioned keystore
...
...
@@ -34,7 +47,7 @@ func loadKey(kv *versioned.KV, id *id.ID) (*key, error) {
}
// saves the key as the key for the given node ID in the passed keystore
func
(
k
*
key
)
save
(
kv
*
versioned
.
KV
,
id
*
id
.
ID
)
error
{
func
(
k
*
key
)
save
()
error
{
now
:=
time
.
Now
()
data
,
err
:=
k
.
marshal
()
...
...
@@ -48,9 +61,7 @@ func (k *key) save(kv *versioned.KV, id *id.ID) error {
Data
:
data
,
}
key
:=
keyKey
(
id
)
return
kv
.
Set
(
key
,
&
obj
)
return
k
.
kv
.
Set
(
k
.
storeKey
,
&
obj
)
}
// deletes the key from the versioned keystore
...
...
This diff is collapsed.
Click to expand it.
storage/cmix/store.go
+
1
−
2
View file @
6e267993
...
...
@@ -77,8 +77,7 @@ func (s *Store) Add(nid *id.ID, k *cyclic.Int) error {
s
.
mux
.
Lock
()
defer
s
.
mux
.
Unlock
()
nodekey
:=
&
key
{
k
:
k
}
err
:=
nodekey
.
save
(
s
.
kv
,
nid
)
nodekey
,
err
:=
NewKey
(
s
.
kv
,
k
,
nid
)
if
err
!=
nil
{
return
err
}
...
...
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