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
6637b5a9
"Sources/ElixxirDAppsSDK/Functors/GetFactsFromContact.swift" did not exist on "10b788a1b388dc41cd296d0cfb7c1395a9b27275"
Commit
6637b5a9
authored
1 year ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
instead of just fixing the mux refactor it as pointered funcs
parent
e8874e44
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ud/channelIDTracking.go
+17
-17
17 additions, 17 deletions
ud/channelIDTracking.go
ud/channelIDTracking_test.go
+3
-2
3 additions, 2 deletions
ud/channelIDTracking_test.go
with
20 additions
and
19 deletions
ud/channelIDTracking.go
+
17
−
17
View file @
6637b5a9
...
@@ -31,17 +31,17 @@ var ErrChannelLeaseSignature = errors.New("failure to validate lease signature")
...
@@ -31,17 +31,17 @@ var ErrChannelLeaseSignature = errors.New("failure to validate lease signature")
// loadRegistrationDisk loads a registrationDisk from the kv
// loadRegistrationDisk loads a registrationDisk from the kv
// and returns the registrationDisk.
// and returns the registrationDisk.
func
loadRegistrationDisk
(
kv
versioned
.
KV
)
(
registrationDisk
,
error
)
{
func
loadRegistrationDisk
(
kv
versioned
.
KV
)
(
*
registrationDisk
,
error
)
{
obj
,
err
:=
kv
.
Get
(
registrationDiskKey
,
registrationDiskVersion
)
obj
,
err
:=
kv
.
Get
(
registrationDiskKey
,
registrationDiskVersion
)
if
err
!=
nil
{
if
err
!=
nil
{
return
registrationDisk
{},
err
return
&
registrationDisk
{},
err
}
}
return
UnmarshallRegistrationDisk
(
obj
.
Data
)
return
UnmarshallRegistrationDisk
(
obj
.
Data
)
}
}
// saveRegistrationDisk saves the given saveRegistrationDisk to
// saveRegistrationDisk saves the given saveRegistrationDisk to
// the given kv.
// the given kv.
func
saveRegistrationDisk
(
kv
versioned
.
KV
,
reg
registrationDisk
)
error
{
func
saveRegistrationDisk
(
kv
versioned
.
KV
,
reg
*
registrationDisk
)
error
{
regBytes
,
err
:=
reg
.
Marshall
()
regBytes
,
err
:=
reg
.
Marshall
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -57,7 +57,7 @@ func saveRegistrationDisk(kv versioned.KV, reg registrationDisk) error {
...
@@ -57,7 +57,7 @@ func saveRegistrationDisk(kv versioned.KV, reg registrationDisk) error {
// registrationDisk is used to encapsulate the channel user's key pair,
// registrationDisk is used to encapsulate the channel user's key pair,
// lease and lease signature.
// lease and lease signature.
type
registrationDisk
struct
{
type
registrationDisk
struct
{
rwmutex
*
sync
.
RWMutex
rwmutex
sync
.
RWMutex
Registered
bool
Registered
bool
PublicKey
ed25519
.
PublicKey
PublicKey
ed25519
.
PublicKey
...
@@ -68,8 +68,8 @@ type registrationDisk struct {
...
@@ -68,8 +68,8 @@ type registrationDisk struct {
// newRegistrationDisk creates a new newRegistrationDisk.
// newRegistrationDisk creates a new newRegistrationDisk.
func
newRegistrationDisk
(
publicKey
ed25519
.
PublicKey
,
privateKey
ed25519
.
PrivateKey
,
func
newRegistrationDisk
(
publicKey
ed25519
.
PublicKey
,
privateKey
ed25519
.
PrivateKey
,
lease
time
.
Time
,
signature
[]
byte
)
registrationDisk
{
lease
time
.
Time
,
signature
[]
byte
)
*
registrationDisk
{
return
registrationDisk
{
return
&
registrationDisk
{
Lease
:
lease
.
UnixNano
(),
Lease
:
lease
.
UnixNano
(),
PublicKey
:
publicKey
,
PublicKey
:
publicKey
,
PrivateKey
:
privateKey
,
PrivateKey
:
privateKey
,
...
@@ -77,7 +77,7 @@ func newRegistrationDisk(publicKey ed25519.PublicKey, privateKey ed25519.Private
...
@@ -77,7 +77,7 @@ func newRegistrationDisk(publicKey ed25519.PublicKey, privateKey ed25519.Private
}
}
}
}
func
(
r
registrationDisk
)
IsRegistered
()
bool
{
func
(
r
*
registrationDisk
)
IsRegistered
()
bool
{
r
.
rwmutex
.
RLock
()
r
.
rwmutex
.
RLock
()
defer
r
.
rwmutex
.
RUnlock
()
defer
r
.
rwmutex
.
RUnlock
()
...
@@ -96,7 +96,7 @@ func (r *registrationDisk) Update(lease int64, signature []byte) {
...
@@ -96,7 +96,7 @@ func (r *registrationDisk) Update(lease int64, signature []byte) {
}
}
// Marshall marshalls the registrationDisk.
// Marshall marshalls the registrationDisk.
func
(
r
registrationDisk
)
Marshall
()
([]
byte
,
error
)
{
func
(
r
*
registrationDisk
)
Marshall
()
([]
byte
,
error
)
{
r
.
rwmutex
.
RLock
()
r
.
rwmutex
.
RLock
()
defer
r
.
rwmutex
.
RUnlock
()
defer
r
.
rwmutex
.
RUnlock
()
...
@@ -104,17 +104,17 @@ func (r registrationDisk) Marshall() ([]byte, error) {
...
@@ -104,17 +104,17 @@ func (r registrationDisk) Marshall() ([]byte, error) {
}
}
// UnmarshallRegistrationDisk unmarshalls a registrationDisk
// UnmarshallRegistrationDisk unmarshalls a registrationDisk
func
UnmarshallRegistrationDisk
(
data
[]
byte
)
(
registrationDisk
,
error
)
{
func
UnmarshallRegistrationDisk
(
data
[]
byte
)
(
*
registrationDisk
,
error
)
{
var
r
registrationDisk
var
r
registrationDisk
err
:=
json
.
Unmarshal
(
data
,
&
r
)
err
:=
json
.
Unmarshal
(
data
,
&
r
)
if
err
!=
nil
{
if
err
!=
nil
{
return
registrationDisk
{},
err
return
&
registrationDisk
{},
err
}
}
return
r
,
nil
return
&
r
,
nil
}
}
// GetLease returns the current registrationDisk lease.
// GetLease returns the current registrationDisk lease.
func
(
r
registrationDisk
)
GetLease
()
time
.
Time
{
func
(
r
*
registrationDisk
)
GetLease
()
time
.
Time
{
r
.
rwmutex
.
RLock
()
r
.
rwmutex
.
RLock
()
defer
r
.
rwmutex
.
RUnlock
()
defer
r
.
rwmutex
.
RUnlock
()
...
@@ -122,7 +122,7 @@ func (r registrationDisk) GetLease() time.Time {
...
@@ -122,7 +122,7 @@ func (r registrationDisk) GetLease() time.Time {
}
}
// GetPublicKey returns the current public key.
// GetPublicKey returns the current public key.
func
(
r
registrationDisk
)
GetPublicKey
()
ed25519
.
PublicKey
{
func
(
r
*
registrationDisk
)
GetPublicKey
()
ed25519
.
PublicKey
{
r
.
rwmutex
.
RLock
()
r
.
rwmutex
.
RLock
()
defer
r
.
rwmutex
.
RUnlock
()
defer
r
.
rwmutex
.
RUnlock
()
...
@@ -132,7 +132,7 @@ func (r registrationDisk) GetPublicKey() ed25519.PublicKey {
...
@@ -132,7 +132,7 @@ func (r registrationDisk) GetPublicKey() ed25519.PublicKey {
}
}
// GetPrivateKey returns the current private key.
// GetPrivateKey returns the current private key.
func
(
r
registrationDisk
)
getPrivateKey
()
ed25519
.
PrivateKey
{
func
(
r
*
registrationDisk
)
getPrivateKey
()
ed25519
.
PrivateKey
{
r
.
rwmutex
.
RLock
()
r
.
rwmutex
.
RLock
()
defer
r
.
rwmutex
.
RUnlock
()
defer
r
.
rwmutex
.
RUnlock
()
...
@@ -140,7 +140,7 @@ func (r registrationDisk) getPrivateKey() ed25519.PrivateKey {
...
@@ -140,7 +140,7 @@ func (r registrationDisk) getPrivateKey() ed25519.PrivateKey {
}
}
// GetLeaseSignature returns the currentl signature and lease time.
// GetLeaseSignature returns the currentl signature and lease time.
func
(
r
registrationDisk
)
GetLeaseSignature
()
([]
byte
,
time
.
Time
)
{
func
(
r
*
registrationDisk
)
GetLeaseSignature
()
([]
byte
,
time
.
Time
)
{
r
.
rwmutex
.
RLock
()
r
.
rwmutex
.
RLock
()
defer
r
.
rwmutex
.
RUnlock
()
defer
r
.
rwmutex
.
RUnlock
()
...
@@ -182,7 +182,7 @@ func newclientIDTracker(comms channelLeaseComms, host *connect.Host, username st
...
@@ -182,7 +182,7 @@ func newclientIDTracker(comms channelLeaseComms, host *connect.Host, username st
jww
.
FATAL
.
Panic
(
err
)
jww
.
FATAL
.
Panic
(
err
)
}
}
reg
=
registrationDisk
{
reg
=
&
registrationDisk
{
PublicKey
:
publicKey
,
PublicKey
:
publicKey
,
PrivateKey
:
privateKey
,
PrivateKey
:
privateKey
,
Lease
:
0
,
Lease
:
0
,
...
@@ -198,7 +198,7 @@ func newclientIDTracker(comms channelLeaseComms, host *connect.Host, username st
...
@@ -198,7 +198,7 @@ func newclientIDTracker(comms channelLeaseComms, host *connect.Host, username st
c
:=
&
clientIDTracker
{
c
:=
&
clientIDTracker
{
kv
:
kv
,
kv
:
kv
,
rngSource
:
rngSource
,
rngSource
:
rngSource
,
registrationDisk
:
&
reg
,
registrationDisk
:
reg
,
receptionIdentity
:
&
receptionIdentity
,
receptionIdentity
:
&
receptionIdentity
,
username
:
username
,
username
:
username
,
comms
:
comms
,
comms
:
comms
,
...
...
This diff is collapsed.
Click to expand it.
ud/channelIDTracking_test.go
+
3
−
2
View file @
6637b5a9
...
@@ -62,14 +62,15 @@ func TestLoadSaveRegistration(t *testing.T) {
...
@@ -62,14 +62,15 @@ func TestLoadSaveRegistration(t *testing.T) {
kv
:=
versioned
.
NewKV
(
ekv
.
MakeMemstore
())
kv
:=
versioned
.
NewKV
(
ekv
.
MakeMemstore
())
registrationDisk
,
err
:=
loadRegistrationDisk
(
kv
)
// Check if it exists first
_
,
err
=
loadRegistrationDisk
(
kv
)
require
.
Error
(
t
,
err
)
require
.
Error
(
t
,
err
)
require
.
False
(
t
,
kv
.
Exists
(
err
))
require
.
False
(
t
,
kv
.
Exists
(
err
))
err
=
saveRegistrationDisk
(
kv
,
reg
)
err
=
saveRegistrationDisk
(
kv
,
reg
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
registrationDisk
,
err
=
loadRegistrationDisk
(
kv
)
registrationDisk
,
err
:
=
loadRegistrationDisk
(
kv
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
registrationDisk
,
reg
)
require
.
Equal
(
t
,
registrationDisk
,
reg
)
}
}
...
...
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