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
1e7552fe
Commit
1e7552fe
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
added support for base NDF
parent
021ceb27
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
storage/ndf.go
+30
-0
30 additions, 0 deletions
storage/ndf.go
storage/session.go
+3
-0
3 additions, 0 deletions
storage/session.go
storage/utility/NDF.go
+40
-0
40 additions, 0 deletions
storage/utility/NDF.go
with
73 additions
and
0 deletions
storage/ndf.go
0 → 100644
+
30
−
0
View file @
1e7552fe
package
storage
import
(
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/storage/utility"
"gitlab.com/xx_network/primitives/ndf"
)
const
baseNdfKey
=
"baseNdf"
func
(
s
*
Session
)
SetBaseNDF
(
def
*
ndf
.
NetworkDefinition
)
{
err
:=
utility
.
SaveNDF
(
s
.
kv
,
baseNdfKey
,
def
)
if
err
!=
nil
{
jww
.
FATAL
.
Printf
(
"Failed to dave the base NDF: %s"
,
err
)
}
s
.
baseNdf
=
def
}
func
(
s
*
Session
)
GetBaseNDF
()
*
ndf
.
NetworkDefinition
{
if
s
.
baseNdf
!=
nil
{
return
s
.
baseNdf
}
def
,
err
:=
utility
.
LoadNDF
(
s
.
kv
,
baseNdfKey
)
if
err
!=
nil
{
jww
.
FATAL
.
Printf
(
"Could not load the base NDF: %s"
,
err
)
}
s
.
baseNdf
=
def
return
def
}
This diff is collapsed.
Click to expand it.
storage/session.go
+
3
−
0
View file @
1e7552fe
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"gitlab.com/elixxir/ekv"
"gitlab.com/elixxir/ekv"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf"
"sync"
"sync"
"testing"
"testing"
)
)
...
@@ -36,7 +37,9 @@ type Session struct {
...
@@ -36,7 +37,9 @@ type Session struct {
kv
*
versioned
.
KV
kv
*
versioned
.
KV
mux
sync
.
RWMutex
mux
sync
.
RWMutex
//memoized data
regStatus
RegistrationStatus
regStatus
RegistrationStatus
baseNdf
*
ndf
.
NetworkDefinition
//sub-stores
//sub-stores
e2e
*
e2e
.
Store
e2e
*
e2e
.
Store
...
...
This diff is collapsed.
Click to expand it.
storage/utility/NDF.go
0 → 100644
+
40
−
0
View file @
1e7552fe
package
utility
import
(
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/ndf"
"time"
)
const
currentNDFVersion
=
0
func
LoadNDF
(
kv
*
versioned
.
KV
,
key
string
)
(
*
ndf
.
NetworkDefinition
,
error
)
{
vo
,
err
:=
kv
.
Get
(
key
)
if
err
!=
nil
{
return
nil
,
err
}
ndf
,
_
,
err
:=
ndf
.
DecodeNDF
(
string
(
vo
.
Data
))
if
err
!=
nil
{
return
nil
,
err
}
return
ndf
,
err
}
func
SaveNDF
(
kv
*
versioned
.
KV
,
key
string
,
ndf
*
ndf
.
NetworkDefinition
)
error
{
marshaled
,
err
:=
ndf
.
Marshal
()
if
err
!=
nil
{
return
err
}
now
:=
time
.
Now
()
obj
:=
versioned
.
Object
{
Version
:
currentNDFVersion
,
Timestamp
:
now
,
Data
:
marshaled
,
}
return
kv
.
Set
(
key
,
&
obj
)
}
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