Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
xx network
comms
Commits
a93ded09
Commit
a93ded09
authored
May 5, 2021
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
protected context building
parent
17962663
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
connect/auth.go
+2
-2
2 additions, 2 deletions
connect/auth.go
connect/context.go
+2
-2
2 additions, 2 deletions
connect/context.go
connect/host.go
+5
-4
5 additions, 4 deletions
connect/host.go
interconnect/consensusClient.go
+1
-1
1 addition, 1 deletion
interconnect/consensusClient.go
with
10 additions
and
9 deletions
connect/auth.go
+
2
−
2
View file @
a93ded09
...
...
@@ -44,7 +44,7 @@ func (c *ProtoComms) clientHandshake(host *Host) (err error) {
// Set up the context
client
:=
pb
.
NewGenericClient
(
host
.
connection
)
ctx
,
cancel
:=
MessagingContext
(
host
.
GetSendTimeout
()
)
ctx
,
cancel
:=
host
.
Get
MessagingContext
()
defer
cancel
()
// Send the token request message
...
...
@@ -75,7 +75,7 @@ func (c *ProtoComms) clientHandshake(host *Host) (err error) {
}
// Set up the context
ctx
,
cancel
=
MessagingContext
(
host
.
GetSendTimeout
()
)
ctx
,
cancel
=
host
.
Get
MessagingContext
()
defer
cancel
()
// Send the authenticate token message
...
...
This diff is collapsed.
Click to expand it.
connect/context.go
+
2
−
2
View file @
a93ded09
...
...
@@ -17,8 +17,8 @@ import (
"time"
)
//
Messaging
Context builds a context for connections and message sending with the given timeout
func
Messaging
Context
(
waitingPeriod
time
.
Duration
)
(
context
.
Context
,
context
.
CancelFunc
)
{
//
new
Context builds a context for connections and message sending with the given timeout
func
new
Context
(
waitingPeriod
time
.
Duration
)
(
context
.
Context
,
context
.
CancelFunc
)
{
jww
.
DEBUG
.
Printf
(
"Timing out in: %s"
,
waitingPeriod
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
waitingPeriod
)
...
...
This diff is collapsed.
Click to expand it.
connect/host.go
+
5
−
4
View file @
a93ded09
...
...
@@ -10,6 +10,7 @@
package
connect
import
(
"context"
"fmt"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
...
...
@@ -167,9 +168,9 @@ func (h *Host) Connected() (bool, uint64) {
return
h
.
isAlive
()
&&
!
h
.
authenticationRequired
(),
h
.
connectionCount
}
// Get
SendTimeout returns the timeout for message sending
func
(
h
*
Host
)
Get
SendTimeout
()
time
.
Duration
{
return
h
.
params
.
SendTimeout
// Get
MessagingContext returns a context object for message sending configured according to HostParams
func
(
h
*
Host
)
Get
MessagingContext
()
(
context
.
Context
,
context
.
CancelFunc
)
{
return
newContext
(
h
.
params
.
SendTimeout
)
}
// GetId returns the id of the host
...
...
@@ -375,7 +376,7 @@ func (h *Host) connectHelper() (err error) {
if
backoffTime
>
15000
{
backoffTime
=
15000
}
ctx
,
cancel
:=
Messaging
Context
(
time
.
Duration
(
backoffTime
)
*
time
.
Millisecond
)
ctx
,
cancel
:=
new
Context
(
time
.
Duration
(
backoffTime
)
*
time
.
Millisecond
)
// Create the connection
h
.
connection
,
err
=
grpc
.
DialContext
(
ctx
,
h
.
GetAddress
(),
...
...
This diff is collapsed.
Click to expand it.
interconnect/consensusClient.go
+
1
−
1
View file @
a93ded09
...
...
@@ -26,7 +26,7 @@ func (c *CMixServer) GetNdf(host *connect.Host,
// Create the Send Function
f
:=
func
(
conn
*
grpc
.
ClientConn
)
(
*
any
.
Any
,
error
)
{
// Set up the context
ctx
,
cancel
:=
connect
.
MessagingContext
(
host
.
GetSendTimeout
()
)
ctx
,
cancel
:=
host
.
Get
MessagingContext
()
defer
cancel
()
//Format to authenticated message type
// Send the message
...
...
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
sign in
to comment