Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
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
elixxir
comms
Commits
c49079c6
Commit
c49079c6
authored
Mar 9, 2021
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Clean up code
parent
2dfb1d79
No related branches found
No related tags found
1 merge request
!58
Revert "Modify waiting lock"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
network/dataStructures/waitingRounds.go
+0
-8
0 additions, 8 deletions
network/dataStructures/waitingRounds.go
network/instance.go
+7
-7
7 additions, 7 deletions
network/instance.go
network/validation.go
+16
-0
16 additions, 0 deletions
network/validation.go
with
23 additions
and
15 deletions
network/dataStructures/waitingRounds.go
+
0
−
8
View file @
c49079c6
...
@@ -8,7 +8,6 @@ package dataStructures
...
@@ -8,7 +8,6 @@ package dataStructures
import
(
import
(
"container/list"
"container/list"
"fmt"
"github.com/golang-collections/collections/set"
"github.com/golang-collections/collections/set"
"github.com/pkg/errors"
"github.com/pkg/errors"
pb
"gitlab.com/elixxir/comms/mixmessages"
pb
"gitlab.com/elixxir/comms/mixmessages"
...
@@ -59,7 +58,6 @@ func (wr *WaitingRounds) Insert(newRound *Round) {
...
@@ -59,7 +58,6 @@ func (wr *WaitingRounds) Insert(newRound *Round) {
for
e
:=
wr
.
rounds
.
Back
();
e
!=
nil
;
e
=
e
.
Prev
()
{
for
e
:=
wr
.
rounds
.
Back
();
e
!=
nil
;
e
=
e
.
Prev
()
{
// If the new round is larger, than add it before
// If the new round is larger, than add it before
extractedRound
:=
e
.
Value
.
(
*
Round
)
extractedRound
:=
e
.
Value
.
(
*
Round
)
// todo: check no panics occur
if
getTime
(
newRound
)
>
getTime
(
extractedRound
)
{
if
getTime
(
newRound
)
>
getTime
(
extractedRound
)
{
wr
.
rounds
.
InsertAfter
(
newRound
,
e
)
wr
.
rounds
.
InsertAfter
(
newRound
,
e
)
...
@@ -96,7 +94,6 @@ func (wr *WaitingRounds) remove(newRound *Round) {
...
@@ -96,7 +94,6 @@ func (wr *WaitingRounds) remove(newRound *Round) {
// Look for a node with a matching ID from the list
// Look for a node with a matching ID from the list
for
e
:=
wr
.
rounds
.
Back
();
e
!=
nil
;
e
=
e
.
Prev
()
{
for
e
:=
wr
.
rounds
.
Back
();
e
!=
nil
;
e
=
e
.
Prev
()
{
extractedRound
:=
e
.
Value
.
(
*
Round
)
extractedRound
:=
e
.
Value
.
(
*
Round
)
// todo: check no panics occur
if
extractedRound
.
info
.
ID
==
newRound
.
info
.
ID
{
if
extractedRound
.
info
.
ID
==
newRound
.
info
.
ID
{
wr
.
rounds
.
Remove
(
e
)
wr
.
rounds
.
Remove
(
e
)
return
return
...
@@ -118,7 +115,6 @@ func (wr *WaitingRounds) getFurthest(exclude *set.Set) *Round {
...
@@ -118,7 +115,6 @@ func (wr *WaitingRounds) getFurthest(exclude *set.Set) *Round {
// If no rounds are excluded, return the last round in the list
// If no rounds are excluded, return the last round in the list
if
exclude
==
nil
{
if
exclude
==
nil
{
fmt
.
Println
(
"exclude is nil "
)
return
wr
.
rounds
.
Back
()
.
Value
.
(
*
Round
)
return
wr
.
rounds
.
Back
()
.
Value
.
(
*
Round
)
}
}
...
@@ -126,9 +122,6 @@ func (wr *WaitingRounds) getFurthest(exclude *set.Set) *Round {
...
@@ -126,9 +122,6 @@ func (wr *WaitingRounds) getFurthest(exclude *set.Set) *Round {
// Return the last non-excluded round in the list
// Return the last non-excluded round in the list
for
e
:=
wr
.
rounds
.
Back
();
e
!=
nil
;
e
=
e
.
Prev
()
{
for
e
:=
wr
.
rounds
.
Back
();
e
!=
nil
;
e
=
e
.
Prev
()
{
r
:=
e
.
Value
.
(
*
Round
)
r
:=
e
.
Value
.
(
*
Round
)
fmt
.
Printf
(
"r val: %v
\n
"
,
r
)
fmt
.
Printf
(
"r info: %v
\n
"
,
r
.
info
)
if
!
exclude
.
Has
(
r
)
{
if
!
exclude
.
Has
(
r
)
{
return
r
return
r
}
}
...
@@ -150,7 +143,6 @@ func (wr *WaitingRounds) GetSlice() []*pb.RoundInfo {
...
@@ -150,7 +143,6 @@ func (wr *WaitingRounds) GetSlice() []*pb.RoundInfo {
for
e
,
i
:=
wr
.
rounds
.
Front
(),
0
;
e
!=
nil
;
e
,
i
=
e
.
Next
(),
i
+
1
{
for
e
,
i
:=
wr
.
rounds
.
Front
(),
0
;
e
!=
nil
;
e
,
i
=
e
.
Next
(),
i
+
1
{
iter
++
iter
++
extractedRound
:=
e
.
Value
.
(
*
Round
)
extractedRound
:=
e
.
Value
.
(
*
Round
)
// todo: check no panics occur
if
getTime
(
extractedRound
)
>
now
{
if
getTime
(
extractedRound
)
>
now
{
roundInfos
=
append
(
roundInfos
,
extractedRound
.
info
)
roundInfos
=
append
(
roundInfos
,
extractedRound
.
info
)
}
}
...
...
This diff is collapsed.
Click to expand it.
network/instance.go
+
7
−
7
View file @
c49079c6
...
@@ -462,15 +462,15 @@ func (i *Instance) RoundUpdate(info *pb.RoundInfo) error {
...
@@ -462,15 +462,15 @@ func (i *Instance) RoundUpdate(info *pb.RoundInfo) error {
}
}
rnd
:=
ds
.
NewRound
(
info
,
perm
.
GetPubKey
())
rnd
:=
ds
.
NewRound
(
info
,
perm
.
GetPubKey
())
if
i
.
validationLevel
==
Strict
{
// todo: modify here
err
:=
signature
.
Verify
(
info
,
perm
.
GetPubKey
())
err
:=
signature
.
Verify
(
info
,
perm
.
GetPubKey
())
if
err
!=
nil
{
if
err
!=
nil
{
return
errors
.
WithMessage
(
err
,
fmt
.
Sprintf
(
"Could not validate "
+
return
errors
.
WithMessage
(
err
,
fmt
.
Sprintf
(
"Could not validate "
+
"the roundInfo signature: %+v"
,
info
))
"the roundInfo signature: %+v"
,
info
))
}
}
}
err
=
i
.
roundUpdates
.
AddRound
(
rnd
)
err
:
=
i
.
roundUpdates
.
AddRound
(
rnd
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
This diff is collapsed.
Click to expand it.
network/validation.go
+
16
−
0
View file @
c49079c6
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
package
network
package
network
import
"fmt"
// Level of validation types for pulling our round structure
// Level of validation types for pulling our round structure
// Strict: Signatures are checked every time (intended for nodes)
// Strict: Signatures are checked every time (intended for nodes)
// Lazy: Only check we're involved, only verifies the first retrieval
// Lazy: Only check we're involved, only verifies the first retrieval
...
@@ -17,3 +19,17 @@ const (
...
@@ -17,3 +19,17 @@ const (
Lazy
Lazy
None
None
)
)
// Stringer for ValidationType
func
(
s
ValidationType
)
String
()
string
{
switch
s
{
case
Strict
:
return
"Strict"
case
Lazy
:
return
"Lazy"
case
None
:
return
"None"
default
:
return
fmt
.
Sprintf
(
"UNKNOWN STATE: %d"
,
s
)
}
}
\ No newline at end of file
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