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
f8a7eb29
Commit
f8a7eb29
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add check if we were initially loaded as a legacy system
parent
b5c2cfd4
No related branches found
No related tags found
1 merge request
!510
Release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
e2e/manager.go
+20
-5
20 additions, 5 deletions
e2e/manager.go
with
20 additions
and
5 deletions
e2e/manager.go
+
20
−
5
View file @
f8a7eb29
...
...
@@ -2,10 +2,10 @@ package e2e
import
(
"encoding/json"
jww
"github.com/spf13/jwalterweatherman"
"strings"
"time"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/xx_network/primitives/netTime"
"github.com/pkg/errors"
...
...
@@ -39,6 +39,7 @@ type manager struct {
kv
*
versioned
.
KV
}
const
legacyE2EKey
=
"legacyE2ESystem"
const
e2eRekeyParamsKey
=
"e2eRekeyParams"
const
e2eRekeyParamsVer
=
0
...
...
@@ -102,9 +103,12 @@ func LoadLegacy(kv *versioned.KV, net cmix.Client, myID *id.ID,
// Check if values are already written. If they exist on disk/memory already,
// this would be a case where LoadLegacy is most likely not the correct
// code-path the caller should be following.
if
_
,
err
:=
kv
.
Get
(
e2eRekeyParamsKey
,
e2eRekeyParamsVer
);
err
!=
nil
&&
!
strings
.
Contains
(
err
.
Error
(),
"object not found"
)
{
return
nil
,
errors
.
New
(
"E2E rekey params are already on disk, "
+
"LoadLegacy should not be called"
)
if
_
,
err
:=
kv
.
Get
(
e2eRekeyParamsKey
,
e2eRekeyParamsVer
);
err
==
nil
{
if
_
,
err
=
kv
.
Get
(
legacyE2EKey
,
e2eRekeyParamsVer
);
err
!=
nil
{
return
nil
,
errors
.
New
(
"E2E rekey params"
+
" are already on disk, "
+
"LoadLegacy should not be called"
)
}
}
// Store the rekey params to disk/memory
...
...
@@ -113,6 +117,17 @@ func LoadLegacy(kv *versioned.KV, net cmix.Client, myID *id.ID,
Timestamp
:
netTime
.
Now
(),
Data
:
rekeyParamsData
,
})
if
err
!=
nil
{
return
nil
,
err
}
err
=
kv
.
Set
(
legacyE2EKey
,
e2eRekeyParamsVer
,
&
versioned
.
Object
{
Version
:
e2eRekeyParamsVer
,
Timestamp
:
netTime
.
Now
(),
Data
:
[]
byte
{
1
},
})
if
err
!=
nil
{
return
nil
,
err
}
// Load the legacy data
return
loadE2E
(
kv
,
net
,
myID
,
grp
,
rng
,
events
)
...
...
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