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
178d4024
Commit
178d4024
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
we don't actually need a legacy loader or a version update here
parent
6aae9bb6
No related branches found
No related tags found
2 merge requests
!510
Release
,
!282
Auth Store Fixes
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/utility/contact.go
+2
-36
2 additions, 36 deletions
storage/utility/contact.go
with
2 additions
and
36 deletions
storage/utility/contact.go
+
2
−
36
View file @
178d4024
...
...
@@ -10,16 +10,13 @@ package utility
import
(
"fmt"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/ekv"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
)
const
currentContactVersion
=
1
const
currentContactVersion
=
0
// StoreContact writes a contact into a versioned.KV using the
// contact ID as the key.
...
...
@@ -53,16 +50,8 @@ func StoreContact(kv *versioned.KV, c contact.Contact) error {
func
LoadContact
(
kv
*
versioned
.
KV
,
cid
*
id
.
ID
)
(
contact
.
Contact
,
error
)
{
vo
,
err
:=
kv
.
Get
(
makeContactKey
(
cid
),
currentContactVersion
)
if
err
!=
nil
{
c
,
contactErr
:=
loadLegacyContactV0
(
kv
,
cid
)
// If we got an error on loading legacy contact, and it's not
// a missing object error, then return a wrapped error
if
contactErr
!=
nil
&&
ekv
.
Exists
(
contactErr
)
{
return
c
,
errors
.
Wrapf
(
err
,
"%+v"
,
contactErr
)
}
else
if
contactErr
!=
nil
&&
!
ekv
.
Exists
(
contactErr
)
{
return
contact
.
Contact
{},
err
}
return
c
,
nil
}
return
contact
.
Unmarshal
(
vo
.
Data
)
}
...
...
@@ -81,26 +70,3 @@ func DeleteContact(kv *versioned.KV, cid *id.ID) error {
func
makeContactKey
(
cid
*
id
.
ID
)
string
{
return
fmt
.
Sprintf
(
"Contact:%s"
,
cid
)
}
func
loadLegacyContactV0
(
kv
*
versioned
.
KV
,
cid
*
id
.
ID
)
(
contact
.
Contact
,
error
)
{
vo
,
err
:=
kv
.
Get
(
makeContactKey
(
cid
),
0
)
if
err
!=
nil
{
return
contact
.
Contact
{},
err
}
jww
.
DEBUG
.
Printf
(
"Upgrading legacy V0 contact..."
)
c
,
err
:=
contact
.
Unmarshal
(
vo
.
Data
)
if
err
!=
nil
{
return
contact
.
Contact
{},
err
}
err
=
StoreContact
(
kv
,
c
)
if
err
!=
nil
{
return
contact
.
Contact
{},
err
}
kv
.
Delete
(
makeContactKey
(
cid
),
0
)
return
c
,
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