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
0c29cd26
Commit
0c29cd26
authored
3 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
Changes by Benjamin
parent
fc6bc486
No related branches found
No related tags found
2 merge requests
!53
Release
,
!26
Protonet
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
interfaces/params/network.go
+4
-0
4 additions, 0 deletions
interfaces/params/network.go
storage/rounds/unknownRounds.go
+4
-1
4 additions, 1 deletion
storage/rounds/unknownRounds.go
storage/rounds/unknownRounds_test.go
+4
-4
4 additions, 4 deletions
storage/rounds/unknownRounds_test.go
with
12 additions
and
5 deletions
interfaces/params/network.go
+
4
−
0
View file @
0c29cd26
...
...
@@ -31,6 +31,9 @@ type Network struct {
FastPolling
bool
// Messages will not be sent to Rounds containing these Nodes
BlacklistedNodes
[]
string
// Determines if the state of every round processed is tracked in ram.
// This is very memory intensive and is primarily used for debugging
VerboseRoundTracking
bool
Rounds
Messages
...
...
@@ -50,6 +53,7 @@ func GetDefaultNetwork() Network {
KnownRoundsThreshold
:
1500
,
//5 rounds/sec * 60 sec/min * 5 min
FastPolling
:
true
,
BlacklistedNodes
:
make
([]
string
,
0
),
VerboseRoundTracking
:
false
,
}
n
.
Rounds
=
GetDefaultRounds
()
n
.
Messages
=
GetDefaultMessage
()
...
...
This diff is collapsed.
Click to expand it.
storage/rounds/unknownRounds.go
+
4
−
1
View file @
0c29cd26
...
...
@@ -113,8 +113,9 @@ func LoadUnknownRounds(kv *versioned.KV,
// in params, it removes from the map
// Afterwards it adds the roundToAdd to the map if an entry isn't present
// Finally it saves the modified map to disk.
// The abandon function can be used to pass the abandoned round somewhere else
func
(
urs
*
UnknownRounds
)
Iterate
(
checker
func
(
rid
id
.
Round
)
bool
,
roundsToAdd
[]
id
.
Round
)
[]
id
.
Round
{
roundsToAdd
[]
id
.
Round
,
abandon
func
(
round
id
.
Round
)
)
[]
id
.
Round
{
returnSlice
:=
make
([]
id
.
Round
,
0
)
urs
.
mux
.
Lock
()
defer
urs
.
mux
.
Unlock
()
...
...
@@ -132,6 +133,8 @@ func (urs *UnknownRounds) Iterate(checker func(rid id.Round) bool,
// If the round has been checked the maximum amount,
// the rond is removed from the map
if
totalChecks
>
urs
.
params
.
MaxChecks
{
localRnd
:=
rnd
go
abandon
(
localRnd
)
delete
(
urs
.
rounds
,
rnd
)
}
}
...
...
This diff is collapsed.
Click to expand it.
storage/rounds/unknownRounds_test.go
+
4
−
4
View file @
0c29cd26
...
...
@@ -86,7 +86,7 @@ func TestUnknownRoundsStore_Iterate(t *testing.T) {
}
// Iterate over initial map
received
:=
store
.
Iterate
(
mockChecker
,
nil
)
received
:=
store
.
Iterate
(
mockChecker
,
nil
,
func
(
round
id
.
Round
)
{
return
}
)
// Check the received list for 2 conditions:
// a) that returned rounds are no longer in the map
...
...
@@ -106,7 +106,7 @@ func TestUnknownRoundsStore_Iterate(t *testing.T) {
}
// Add even round list to map
received
=
store
.
Iterate
(
mockChecker
,
roundListEven
)
received
=
store
.
Iterate
(
mockChecker
,
roundListEven
,
func
(
round
id
.
Round
)
{
return
}
)
if
len
(
received
)
!=
0
{
t
.
Errorf
(
"Second iteration should return an empty list (no even rounds are left)."
+
...
...
@@ -116,7 +116,7 @@ func TestUnknownRoundsStore_Iterate(t *testing.T) {
// Iterate over map until all rounds have checks incremented over
// maxCheck
for
i
:=
0
;
i
<
defaultMaxCheck
+
1
;
i
++
{
_
=
store
.
Iterate
(
mockChecker
,
[]
id
.
Round
{})
_
=
store
.
Iterate
(
mockChecker
,
[]
id
.
Round
{
},
func
(
round
id
.
Round
)
{
return
})
}
...
...
@@ -172,7 +172,7 @@ func TestLoadUnknownRoundsStore(t *testing.T) {
// Check that LoadStore works after iterate call (which implicitly saves)
mockChecker
:=
func
(
round
id
.
Round
)
bool
{
return
false
}
received
:=
store
.
Iterate
(
mockChecker
,
nil
)
received
:=
store
.
Iterate
(
mockChecker
,
nil
,
func
(
round
id
.
Round
)
{
return
}
)
// Iterate is being called as a dummy, should not return anything
if
len
(
received
)
!=
0
{
...
...
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