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
a97d4205
Commit
a97d4205
authored
3 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
removed filtering of the filters because it is un-needed.
parent
fe02e5a7
No related branches found
No related tags found
1 merge request
!170
Release
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
network/follow.go
+2
-11
2 additions, 11 deletions
network/follow.go
network/rounds/remoteFilters.go
+0
-35
0 additions, 35 deletions
network/rounds/remoteFilters.go
network/rounds/remoteFilters_test.go
+1
-113
1 addition, 113 deletions
network/rounds/remoteFilters_test.go
with
3 additions
and
159 deletions
network/follow.go
+
2
−
11
View file @
a97d4205
...
@@ -315,18 +315,9 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
...
@@ -315,18 +315,9 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
return
return
}
}
//get the range fo filters which are valid for the identity
filtersStart
,
filtersEnd
,
outOfBounds
:=
rounds
.
ValidFilterRange
(
identity
,
pollResp
.
Filters
)
//check if there are any valid filters returned
if
outOfBounds
{
jww
.
WARN
.
Printf
(
"No filters processed, none in valid range"
)
return
}
//prepare the filter objects for processing
//prepare the filter objects for processing
filterList
:=
make
([]
*
rounds
.
RemoteFilter
,
0
,
f
ilters
End
-
f
ilters
Start
)
filterList
:=
make
([]
*
rounds
.
RemoteFilter
,
0
,
len
(
pollResp
.
F
ilters
.
F
ilters
)
)
for
i
:=
filtersStart
;
i
<
filtersEnd
;
i
++
{
for
i
:=
range
pollResp
.
Filters
.
Filters
{
if
len
(
pollResp
.
Filters
.
Filters
[
i
]
.
Filter
)
!=
0
{
if
len
(
pollResp
.
Filters
.
Filters
[
i
]
.
Filter
)
!=
0
{
filterList
=
append
(
filterList
,
rounds
.
NewRemoteFilter
(
pollResp
.
Filters
.
Filters
[
i
]))
filterList
=
append
(
filterList
,
rounds
.
NewRemoteFilter
(
pollResp
.
Filters
.
Filters
[
i
]))
}
}
...
...
This diff is collapsed.
Click to expand it.
network/rounds/remoteFilters.go
+
0
−
35
View file @
a97d4205
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
bloom
"gitlab.com/elixxir/bloomfilter"
bloom
"gitlab.com/elixxir/bloomfilter"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
)
)
...
@@ -48,37 +47,3 @@ func (rf *RemoteFilter) FirstRound() id.Round {
...
@@ -48,37 +47,3 @@ func (rf *RemoteFilter) FirstRound() id.Round {
func
(
rf
*
RemoteFilter
)
LastRound
()
id
.
Round
{
func
(
rf
*
RemoteFilter
)
LastRound
()
id
.
Round
{
return
id
.
Round
(
rf
.
data
.
FirstRound
+
uint64
(
rf
.
data
.
RoundRange
))
return
id
.
Round
(
rf
.
data
.
FirstRound
+
uint64
(
rf
.
data
.
RoundRange
))
}
}
// ValidFilterRange calculates which of the returned filters are valid for the identity
func
ValidFilterRange
(
identity
reception
.
IdentityUse
,
filters
*
mixmessages
.
ClientBlooms
)
(
startIdx
int
,
endIdx
int
,
outOfBounds
bool
)
{
outOfBounds
=
false
firstElementTS
:=
filters
.
FirstTimestamp
identityStart
:=
identity
.
StartValid
.
UnixNano
()
identityEnd
:=
identity
.
EndValid
.
UnixNano
()
startIdx
=
int
((
identityStart
-
firstElementTS
)
/
filters
.
Period
)
if
startIdx
<
0
{
startIdx
=
0
}
if
startIdx
>
len
(
filters
.
Filters
)
-
1
{
outOfBounds
=
true
return
startIdx
,
endIdx
,
outOfBounds
}
endIdx
=
int
((
identityEnd
-
firstElementTS
)
/
filters
.
Period
)
if
endIdx
<
0
{
outOfBounds
=
true
return
startIdx
,
endIdx
,
outOfBounds
}
if
endIdx
>
len
(
filters
.
Filters
)
-
1
{
endIdx
=
len
(
filters
.
Filters
)
-
1
}
// Add 1 to the end index so that it follows Go's convention; the last index
// is exclusive to the range
return
startIdx
,
endIdx
+
1
,
outOfBounds
}
This diff is collapsed.
Click to expand it.
network/rounds/remoteFilters_test.go
+
1
−
113
View file @
a97d4205
...
@@ -11,15 +11,12 @@ import (
...
@@ -11,15 +11,12 @@ import (
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
bloom
"gitlab.com/elixxir/bloomfilter"
bloom
"gitlab.com/elixxir/bloomfilter"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"os"
"os"
"reflect"
"reflect"
"testing"
"testing"
"time"
)
)
func
TestMain
(
m
*
testing
.
M
)
{
func
TestMain
(
m
*
testing
.
M
)
{
...
@@ -102,112 +99,3 @@ func TestRemoteFilter_FirstLastRound(t *testing.T) {
...
@@ -102,112 +99,3 @@ func TestRemoteFilter_FirstLastRound(t *testing.T) {
}
}
}
}
\ No newline at end of file
// In bounds test
func
TestValidFilterRange
(
t
*
testing
.
T
)
{
firstRound
:=
uint64
(
25
)
roundRange
:=
uint32
(
75
)
testFilter
,
err
:=
bloom
.
InitByParameters
(
interfaces
.
BloomFilterSize
,
interfaces
.
BloomFilterHashes
)
if
err
!=
nil
{
t
.
Fatalf
(
"GetFilter error: "
+
"Cannot initialize bloom filter for setup: %v"
,
err
)
}
data
,
err
:=
testFilter
.
MarshalBinary
()
if
err
!=
nil
{
t
.
Fatalf
(
"GetFilter error: "
+
"Cannot marshal filter for setup: %v"
,
err
)
}
// Construct an in bounds value
expectedEphID
:=
ephemeral
.
Id
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}
requestGateway
:=
id
.
NewIdFromString
(
ReturningGateway
,
id
.
Gateway
,
t
)
iu
:=
reception
.
IdentityUse
{
Identity
:
reception
.
Identity
{
EphId
:
expectedEphID
,
Source
:
requestGateway
,
StartValid
:
time
.
Now
()
.
Add
(
-
12
*
time
.
Hour
),
EndValid
:
time
.
Now
()
.
Add
(
24
*
time
.
Hour
),
},
}
bloomFilter
:=
&
mixmessages
.
ClientBloom
{
Filter
:
data
,
FirstRound
:
firstRound
,
RoundRange
:
roundRange
,
}
// Fix for test on Windows machines: provides extra buffer between
// time.Now() for the reception.Identity and the mixmessages.ClientBlooms
time
.
Sleep
(
time
.
Millisecond
)
msg
:=
&
mixmessages
.
ClientBlooms
{
Period
:
int64
(
12
*
time
.
Hour
),
FirstTimestamp
:
time
.
Now
()
.
UnixNano
(),
Filters
:
[]
*
mixmessages
.
ClientBloom
{
bloomFilter
},
}
start
,
end
,
outOfBounds
:=
ValidFilterRange
(
iu
,
msg
)
if
outOfBounds
{
t
.
Errorf
(
"ValidFilterRange error: "
+
"Range should not be out of bounds"
)
}
if
start
!=
0
&&
end
!=
1
{
t
.
Errorf
(
"ValidFilterRange error: "
+
"Unexpected indices returned. "
+
"
\n\t
Expected start: %v
\n\t
Received start: %v"
+
"
\n\t
Expected end: %v
\n\t
Received end: %v"
,
0
,
start
,
1
,
end
)
}
}
// out of bounds test
func
TestValidFilterRange_OutBounds
(
t
*
testing
.
T
)
{
firstRound
:=
uint64
(
25
)
roundRange
:=
uint32
(
75
)
testFilter
,
err
:=
bloom
.
InitByParameters
(
interfaces
.
BloomFilterSize
,
interfaces
.
BloomFilterHashes
)
if
err
!=
nil
{
t
.
Fatalf
(
"GetFilter error: "
+
"Cannot initialize bloom filter for setup: %v"
,
err
)
}
data
,
err
:=
testFilter
.
MarshalBinary
()
if
err
!=
nil
{
t
.
Fatalf
(
"GetFilter error: "
+
"Cannot marshal filter for setup: %v"
,
err
)
}
// Construct an in bounds value
expectedEphID
:=
ephemeral
.
Id
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
}
requestGateway
:=
id
.
NewIdFromString
(
ReturningGateway
,
id
.
Gateway
,
t
)
iu
:=
reception
.
IdentityUse
{
Identity
:
reception
.
Identity
{
EphId
:
expectedEphID
,
Source
:
requestGateway
,
StartValid
:
time
.
Now
()
.
Add
(
-
24
*
time
.
Hour
),
EndValid
:
time
.
Now
()
.
Add
(
-
36
*
time
.
Hour
),
},
}
bloomFilter
:=
&
mixmessages
.
ClientBloom
{
Filter
:
data
,
FirstRound
:
firstRound
,
RoundRange
:
roundRange
,
}
msg
:=
&
mixmessages
.
ClientBlooms
{
Period
:
int64
(
12
*
time
.
Hour
),
FirstTimestamp
:
time
.
Now
()
.
UnixNano
(),
Filters
:
[]
*
mixmessages
.
ClientBloom
{
bloomFilter
},
}
_
,
_
,
outOfBounds
:=
ValidFilterRange
(
iu
,
msg
)
if
!
outOfBounds
{
t
.
Errorf
(
"ValidFilterRange error: "
+
"Range should be out of bounds"
)
}
}
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