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
a8193a9a
Commit
a8193a9a
authored
4 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Plain Diff
Merge branch 'hotfix/DivideByZero' into 'release'
fix divide by zero issue See merge request
!502
parents
5c143de2
d48dcd29
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
network/gateway/gateway.go
+8
-3
8 additions, 3 deletions
network/gateway/gateway.go
with
8 additions
and
3 deletions
network/gateway/gateway.go
+
8
−
3
View file @
a8193a9a
...
@@ -23,10 +23,14 @@ type HostGetter interface {
...
@@ -23,10 +23,14 @@ type HostGetter interface {
GetHost
(
hostId
*
id
.
ID
)
(
*
connect
.
Host
,
bool
)
GetHost
(
hostId
*
id
.
ID
)
(
*
connect
.
Host
,
bool
)
}
}
// Get the Host of a random gateway in the NDF
func
Get
(
ndf
*
ndf
.
NetworkDefinition
,
hg
HostGetter
,
rng
io
.
Reader
)
(
*
connect
.
Host
,
error
)
{
func
Get
(
ndf
*
ndf
.
NetworkDefinition
,
hg
HostGetter
,
rng
io
.
Reader
)
(
*
connect
.
Host
,
error
)
{
// Get a random gateway
gwLen
:=
uint32
(
len
(
ndf
.
Gateways
))
gateways
:=
ndf
.
Gateways
if
gwLen
==
0
{
gwIdx
:=
ReadRangeUint32
(
0
,
uint32
(
len
(
gateways
)),
rng
)
return
nil
,
errors
.
Errorf
(
"no gateways available"
)
}
gwIdx
:=
ReadRangeUint32
(
0
,
gwLen
,
rng
)
gwID
,
err
:=
id
.
Unmarshal
(
ndf
.
Nodes
[
gwIdx
]
.
ID
)
gwID
,
err
:=
id
.
Unmarshal
(
ndf
.
Nodes
[
gwIdx
]
.
ID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
WithMessage
(
err
,
"failed to get Gateway"
)
return
nil
,
errors
.
WithMessage
(
err
,
"failed to get Gateway"
)
...
@@ -40,6 +44,7 @@ func Get(ndf *ndf.NetworkDefinition, hg HostGetter, rng io.Reader) (*connect.Hos
...
@@ -40,6 +44,7 @@ func Get(ndf *ndf.NetworkDefinition, hg HostGetter, rng io.Reader) (*connect.Hos
return
gwHost
,
nil
return
gwHost
,
nil
}
}
// Get the last gateway Host from the given RoundInfo
func
GetLast
(
hg
HostGetter
,
ri
*
mixmessages
.
RoundInfo
)
(
*
connect
.
Host
,
error
)
{
func
GetLast
(
hg
HostGetter
,
ri
*
mixmessages
.
RoundInfo
)
(
*
connect
.
Host
,
error
)
{
roundTop
:=
ri
.
GetTopology
()
roundTop
:=
ri
.
GetTopology
()
lastGw
,
err
:=
id
.
Unmarshal
(
roundTop
[
len
(
roundTop
)
-
1
])
lastGw
,
err
:=
id
.
Unmarshal
(
roundTop
[
len
(
roundTop
)
-
1
])
...
...
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