Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk Examples
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
elixxir
xxdk Examples
Commits
86ee1034
Commit
86ee1034
authored
Jul 12, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Refer to xxdk.Cmix/E2E as net/messenger
parent
0f0d7ae3
No related branches found
No related tags found
1 merge request
!6
Rest connect
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
e2eClient/main.go
+10
-10
10 additions, 10 deletions
e2eClient/main.go
with
10 additions
and
10 deletions
e2eClient/main.go
+
10
−
10
View file @
86ee1034
...
...
@@ -71,21 +71,21 @@ func main() {
// Login to your client session-----------------------------------------------------
// Login with the same sessionPath and sessionPass used to call NewClient()
baseClie
nt
,
err
:=
xxdk
.
LoadCmix
(
statePath
,
[]
byte
(
statePass
),
xxdk
.
GetDefaultCMixParams
())
n
e
t
,
err
:=
xxdk
.
LoadCmix
(
statePath
,
[]
byte
(
statePass
),
xxdk
.
GetDefaultCMixParams
())
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to load state: %+v"
,
err
)
}
// Get reception identity (automatically created if one does not exist)
identityStorageKey
:=
"identityStorageKey"
identity
,
err
:=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
baseClie
nt
)
identity
,
err
:=
xxdk
.
LoadReceptionIdentity
(
identityStorageKey
,
n
e
t
)
if
err
!=
nil
{
// If no extant xxdk.ReceptionIdentity, generate and store a new one
identity
,
err
=
xxdk
.
MakeReceptionIdentity
(
baseClie
nt
)
identity
,
err
=
xxdk
.
MakeReceptionIdentity
(
n
e
t
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to generate reception identity: %+v"
,
err
)
}
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
baseClie
nt
)
err
=
xxdk
.
StoreReceptionIdentity
(
identityStorageKey
,
identity
,
n
e
t
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to store new reception identity: %+v"
,
err
)
}
...
...
@@ -98,17 +98,17 @@ func main() {
params
:=
xxdk
.
GetDefaultE2EParams
()
jww
.
INFO
.
Printf
(
"Using E2E parameters: %+v"
,
params
)
confirmChan
:=
make
(
chan
contact
.
Contact
,
5
)
xxdkClient
,
err
:=
xxdk
.
Login
(
baseClie
nt
,
&
auth
{
confirmChan
:
confirmChan
},
identity
,
params
)
messenger
,
err
:=
xxdk
.
Login
(
n
e
t
,
&
auth
{
confirmChan
:
confirmChan
},
identity
,
params
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Unable to Login: %+v"
,
err
)
}
e2eClient
:=
xxdkClient
.
GetE2E
()
e2eClient
:=
messenger
.
GetE2E
()
// Start network threads------------------------------------------------------------
// Set networkFollowerTimeout to a value of your choice (seconds)
networkFollowerTimeout
:=
5
*
time
.
Second
err
=
xxdkClient
.
StartNetworkFollower
(
networkFollowerTimeout
)
err
=
messenger
.
StartNetworkFollower
(
networkFollowerTimeout
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to start network follower: %+v"
,
err
)
}
...
...
@@ -133,7 +133,7 @@ func main() {
// Create a tracker channel to be notified of network changes
connected
:=
make
(
chan
bool
,
10
)
// Provide a callback that will be signalled when network health status changes
xxdkClient
.
GetCmix
()
.
AddHealthCallback
(
messenger
.
GetCmix
()
.
AddHealthCallback
(
func
(
isConnected
bool
)
{
connected
<-
isConnected
})
...
...
@@ -171,7 +171,7 @@ func main() {
// Check that the partner exists, if not send a request
_
,
err
=
e2eClient
.
GetPartner
(
recipientContact
.
ID
)
if
err
!=
nil
{
_
,
err
=
xxdkClient
.
GetAuth
()
.
Request
(
recipientContact
,
fact
.
FactList
{})
_
,
err
=
messenger
.
GetAuth
()
.
Request
(
recipientContact
,
fact
.
FactList
{})
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to send contact request to %s: %+v"
,
recipientContact
.
ID
.
String
(),
err
)
}
...
...
@@ -205,7 +205,7 @@ func main() {
signal
.
Notify
(
c
,
os
.
Interrupt
,
syscall
.
SIGTERM
)
<-
c
err
=
xxdkClient
.
StopNetworkFollower
()
err
=
messenger
.
StopNetworkFollower
()
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to stop network follower: %+v"
,
err
)
}
else
{
...
...
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