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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
e5975400
Commit
e5975400
authored
Apr 21, 2022
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
wfc
parent
206b385f
No related branches found
No related tags found
4 merge requests
!510
Release
,
!207
WIP: Client Restructure
,
!206
Built the connection interface which wraps e2e and auth objects and manages a...
,
!203
Symmetric broadcast
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
connect/connect.go
+21
-34
21 additions, 34 deletions
connect/connect.go
with
21 additions
and
34 deletions
connect/connect.go
+
21
−
34
View file @
e5975400
...
...
@@ -122,10 +122,9 @@ func Connect(recipient contact.Contact, myId *id.ID, rng *fastRNG.StreamGenerato
}
// WaitForConnections assembles a Connection object on the reception-side
// whenever an E2E partnership with a partner.Manager is established.
// and sends it to the given connectionListener. Should be run in its own thread.
func
WaitForConnections
(
connectionListener
chan
Connection
,
myId
*
id
.
ID
,
rng
*
fastRNG
.
StreamGenerator
,
grp
*
cyclic
.
Group
,
net
cmix
.
Client
,
p
Params
)
{
// when an incoming request for an E2E partnership with a partner.Manager is confirmed.
func
WaitForConnections
(
myId
*
id
.
ID
,
rng
*
fastRNG
.
StreamGenerator
,
grp
*
cyclic
.
Group
,
net
cmix
.
Client
,
p
Params
)
(
Connection
,
error
)
{
// Build an ephemeral KV
kv
:=
versioned
.
NewKV
(
ekv
.
MakeMemstore
())
...
...
@@ -133,8 +132,7 @@ func WaitForConnections(connectionListener chan Connection,
// Build E2e handler
e2eHandler
,
err
:=
clientE2e
.
Load
(
kv
,
net
,
myId
,
grp
,
rng
,
p
.
event
)
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Unable to WaitForConnections: %+v"
,
err
)
return
return
nil
,
err
}
// Build callback for E2E negotiation
...
...
@@ -144,37 +142,26 @@ func WaitForConnections(connectionListener chan Connection,
_
,
err
=
auth
.
NewState
(
kv
,
net
,
e2eHandler
,
rng
,
p
.
event
,
p
.
auth
,
callback
,
nil
)
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Unable to WaitForConnections: %+v"
,
err
)
return
return
nil
,
err
}
for
{
// Block waiting for incoming auth request
jww
.
DEBUG
.
Printf
(
"Connection waiting for auth request to be received..."
)
select
{
case
newPartnerId
:=
<-
callback
.
confirmPartner
:
newPartnerId
:=
<-
callback
.
confirmPartner
jww
.
DEBUG
.
Printf
(
"Connection auth request for %s confirmed"
,
newPartnerId
.
String
())
// After confirmation, get the new partner
newPartner
,
err
:=
e2eHandler
.
GetPartner
(
newPartnerId
)
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Unable to establish new Connection with partner %s: %+v"
,
err
,
newPartnerId
.
String
())
continue
return
nil
,
err
}
// Send the new Connection object to the connectionListener
select
{
case
connectionListener
<-
&
handler
{
// Return the new Connection object
return
&
handler
{
partner
:
newPartner
,
params
:
p
,
e2e
:
e2eHandler
,
}
:
default
:
jww
.
ERROR
.
Printf
(
"Failed to establish new connection due to channel full."
)
}
}
}
},
nil
}
// ConnectWithPartner assembles a Connection object on the reception-side
...
...
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