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
cb1a4bf7
Commit
cb1a4bf7
authored
Mar 29, 2021
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Send request in separate thread after adding it to the critical messages processing queue
parent
7cd4344a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth/request.go
+48
-43
48 additions, 43 deletions
auth/request.go
with
48 additions
and
43 deletions
auth/request.go
+
48
−
43
View file @
cb1a4bf7
...
@@ -33,12 +33,6 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
...
@@ -33,12 +33,6 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
storage
*
storage
.
Session
,
net
interfaces
.
NetworkManager
)
error
{
storage
*
storage
.
Session
,
net
interfaces
.
NetworkManager
)
error
{
/*edge checks generation*/
/*edge checks generation*/
// check that messages can be sent over the network
if
!
net
.
GetHealthTracker
()
.
IsHealthy
()
{
return
errors
.
New
(
"Cannot create authenticated message "
+
"when the network is not healthy"
)
}
// check that an authenticated channel does not already exists
// check that an authenticated channel does not already exists
if
_
,
err
:=
storage
.
E2e
()
.
GetPartner
(
partner
.
ID
);
err
==
nil
||
if
_
,
err
:=
storage
.
E2e
()
.
GetPartner
(
partner
.
ID
);
err
==
nil
||
!
strings
.
Contains
(
err
.
Error
(),
e2e
.
NoPartnerErrorStr
)
{
!
strings
.
Contains
(
err
.
Error
(),
e2e
.
NoPartnerErrorStr
)
{
...
@@ -145,22 +139,25 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
...
@@ -145,22 +139,25 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
//store the message as a critical message so it will always be sent
//store the message as a critical message so it will always be sent
storage
.
GetCriticalRawMessages
()
.
AddProcessing
(
cmixMsg
,
partner
.
ID
)
storage
.
GetCriticalRawMessages
()
.
AddProcessing
(
cmixMsg
,
partner
.
ID
)
go
func
()
{
jww
.
INFO
.
Printf
(
"Requesting Auth with %s, msgDigest: %s"
,
jww
.
INFO
.
Printf
(
"Requesting Auth with %s, msgDigest: %s"
,
partner
.
ID
,
cmixMsg
.
Digest
())
partner
.
ID
,
cmixMsg
.
Digest
())
/*send message*/
/*send message*/
round
,
_
,
err
:=
net
.
SendCMIX
(
cmixMsg
,
partner
.
ID
,
params
.
GetDefaultCMIX
())
round
,
_
,
err
:=
net
.
SendCMIX
(
cmixMsg
,
partner
.
ID
,
params
.
GetDefaultCMIX
())
if
err
!=
nil
{
if
err
!=
nil
{
// if the send fails just set it to failed, it will but automatically
// if the send fails just set it to failed, it will
// retried
// but automatically retried
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) failed "
+
jww
.
WARN
.
Printf
(
"Auth Request with %s (msgDigest: %s)"
+
"to transmit: %+v"
,
partner
.
ID
,
cmixMsg
.
Digest
(),
err
)
" failed to transmit: %+v"
,
partner
.
ID
,
storage
.
GetCriticalRawMessages
()
.
Failed
(
cmixMsg
,
partner
.
ID
)
cmixMsg
.
Digest
(),
err
)
return
errors
.
WithMessage
(
err
,
"Auth Request Failed to transmit"
)
storage
.
GetCriticalRawMessages
()
.
Failed
(
cmixMsg
,
partner
.
ID
)
}
}
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) sent
on round %d"
,
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) sent
"
+
partner
.
ID
,
cmixMsg
.
Digest
(),
round
)
" on round %d"
,
partner
.
ID
,
cmixMsg
.
Digest
(),
round
)
/*check message delivery*/
/*check message delivery*/
sendResults
:=
make
(
chan
ds
.
EventReturn
,
1
)
sendResults
:=
make
(
chan
ds
.
EventReturn
,
1
)
...
@@ -172,19 +169,27 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
...
@@ -172,19 +169,27 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
success
,
numFailed
,
_
:=
utility
.
TrackResults
(
sendResults
,
1
)
success
,
numFailed
,
_
:=
utility
.
TrackResults
(
sendResults
,
1
)
if
!
success
{
if
!
success
{
if
numFailed
>
0
{
if
numFailed
>
0
{
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) failed "
+
jww
.
WARN
.
Printf
(
"Auth Request with %s "
+
"delivery due to round failure, will retry on reconnect"
,
"(msgDigest: %s) failed "
+
"delivery due to round failure, "
+
"will retry on reconnect"
,
partner
.
ID
,
cmixMsg
.
Digest
())
partner
.
ID
,
cmixMsg
.
Digest
())
}
else
{
}
else
{
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) failed "
+
jww
.
WARN
.
Printf
(
"Auth Request with %s "
+
"delivery due to timeout, will retry on reconnect"
,
"(msgDigest: %s) failed "
+
"delivery due to timeout, "
+
"will retry on reconnect"
,
partner
.
ID
,
cmixMsg
.
Digest
())
partner
.
ID
,
cmixMsg
.
Digest
())
}
}
storage
.
GetCriticalRawMessages
()
.
Failed
(
cmixMsg
,
partner
.
ID
)
storage
.
GetCriticalRawMessages
()
.
Failed
(
cmixMsg
,
partner
.
ID
)
}
else
{
}
else
{
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) delivered "
+
jww
.
INFO
.
Printf
(
"Auth Request with %s (msgDigest: %s) "
+
"sucesfully"
,
partner
.
ID
,
cmixMsg
.
Digest
())
"delivered sucessfully"
,
partner
.
ID
,
storage
.
GetCriticalRawMessages
()
.
Succeeded
(
cmixMsg
,
partner
.
ID
)
cmixMsg
.
Digest
())
storage
.
GetCriticalRawMessages
()
.
Succeeded
(
cmixMsg
,
partner
.
ID
)
}
}
}
return
nil
return
nil
...
...
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