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
1687bbd9
Commit
1687bbd9
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
ephid flag
parent
28794268
No related branches found
No related tags found
2 merge requests
!510
Release
,
!304
pickup subcommand
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/flags.go
+3
-2
3 additions, 2 deletions
cmd/flags.go
cmd/pickup.go
+54
-7
54 additions, 7 deletions
cmd/pickup.go
with
57 additions
and
9 deletions
cmd/flags.go
+
3
−
2
View file @
1687bbd9
...
@@ -152,4 +152,5 @@ const (
...
@@ -152,4 +152,5 @@ const (
///////////////// pickup subcommand flags //////////////////////////////
///////////////// pickup subcommand flags //////////////////////////////
pickupGW
=
"gateway"
pickupGW
=
"gateway"
pickupID
=
"id"
pickupID
=
"id"
pickupEphID
=
"ephid"
)
)
This diff is collapsed.
Click to expand it.
cmd/pickup.go
+
54
−
7
View file @
1687bbd9
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
package
cmd
package
cmd
import
(
import
(
"encoding/binary"
"fmt"
"fmt"
"time"
"time"
...
@@ -55,22 +56,37 @@ var pickupCmd = &cobra.Command{
...
@@ -55,22 +56,37 @@ var pickupCmd = &cobra.Command{
ndf
:=
user
.
GetStorage
()
.
GetNDF
()
ndf
:=
user
.
GetStorage
()
.
GetNDF
()
gwID
:=
getGatewayID
(
ndf
)
gwID
:=
getGatewayID
(
ndf
)
clientID
:=
parseRecipient
(
viper
.
GetString
(
pickupID
))
clientIDStr
:=
viper
.
GetString
(
pickupID
)
var
clientID
*
id
.
ID
if
clientIDStr
!=
""
{
clientID
=
parseRecipient
(
viper
.
GetString
(
pickupID
))
}
eID
:=
viper
.
GetInt64
(
pickupEphID
)
if
eID
!=
0
{
fmt
.
Printf
(
"EphID Override: %d
\n
"
,
eID
)
}
// First we get round info, then we use the timestamps to
// First we get round info, then we use the timestamps to
// calculate the right ephID and retrieve the right bloom filter
// calculate the right ephID and retrieve the right bloom filter
roundInfos
:=
dumpRounds
(
roundIDs
,
user
)
roundInfos
:=
dumpRounds
(
roundIDs
,
user
)
for
i
:=
range
roundInfos
{
for
i
:=
range
roundInfos
{
ri
:=
roundInfos
[
i
]
ri
:=
roundInfos
[
i
]
ephIDs
:=
getEphID
(
clientID
,
uint
(
ri
.
AddressSpaceSize
),
var
ephIDs
[]
ephemeral
.
Id
if
clientID
!=
nil
{
ephIDs
=
getEphID
(
clientID
,
uint
(
ri
.
AddressSpaceSize
),
ri
.
Timestamps
[
states
.
QUEUED
])
ri
.
Timestamps
[
states
.
QUEUED
])
}
else
{
ephIDs
=
append
(
ephIDs
,
int2EphID
(
eID
,
uint
(
ri
.
AddressSpaceSize
)))
}
for
j
:=
range
ephIDs
{
for
j
:=
range
ephIDs
{
ephID
:=
ephIDs
[
j
]
ephID
:=
ephIDs
[
j
]
fmt
.
Printf
(
"Getting messages for %s, %d
\n
"
,
fmt
.
Printf
(
"Getting messages for %s, %d
\n
"
,
ri
.
ID
,
ephID
.
Id
.
Int64
())
ri
.
ID
,
ephID
.
Int64
())
msgRsp
,
err
:=
getMessagesFromRound
(
gwID
,
ri
.
ID
,
msgRsp
,
err
:=
getMessagesFromRound
(
gwID
,
ri
.
ID
,
ephID
.
Id
,
ephID
,
user
.
GetComms
())
user
.
GetComms
())
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"
\n\n
round pickup: %+v
\n\n
"
,
fmt
.
Printf
(
"
\n\n
round pickup: %+v
\n\n
"
,
...
@@ -95,11 +111,37 @@ func init() {
...
@@ -95,11 +111,37 @@ func init() {
"id to check"
)
"id to check"
)
bindFlagHelper
(
pickupID
,
pickupCmd
)
bindFlagHelper
(
pickupID
,
pickupCmd
)
pickupCmd
.
Flags
()
.
Int64P
(
pickupEphID
,
"e"
,
0
,
"ignore id lookup and use this specific eph id (signed int)"
)
bindFlagHelper
(
pickupEphID
,
pickupCmd
)
rootCmd
.
AddCommand
(
pickupCmd
)
rootCmd
.
AddCommand
(
pickupCmd
)
}
}
func
int2EphID
(
in
int64
,
addrSize
uint
)
ephemeral
.
Id
{
var
out
[
8
]
byte
mask
:=
uint64
(
0xFFFFFFFFFFFFFFFF
)
>>
(
64
-
addrSize
)
// NOTE: This is just reversing the Int64() function. I have
// no idea why it was done this way...
x
:=
in
if
x
<
0
{
x
=
^
x
x
=
x
<<
1
x
=
x
|
1
}
else
{
x
=
x
<<
1
}
shifted
:=
uint64
(
x
)
&
mask
fmt
.
Printf
(
"Shifted: %d, %d, %d, %d
\n
"
,
addrSize
,
mask
,
in
,
shifted
)
binary
.
BigEndian
.
PutUint64
(
out
[
:
],
shifted
)
return
ephemeral
.
Id
(
out
)
}
func
getEphID
(
id
*
id
.
ID
,
addrSize
uint
,
func
getEphID
(
id
*
id
.
ID
,
addrSize
uint
,
roundStart
time
.
Time
)
[]
ephemeral
.
ProtoIdentity
{
roundStart
time
.
Time
)
[]
ephemeral
.
Id
{
fmt
.
Printf
(
"Getting EphIDs for %s"
,
roundStart
)
fmt
.
Printf
(
"Getting EphIDs for %s"
,
roundStart
)
...
@@ -115,7 +157,12 @@ func getEphID(id *id.ID, addrSize uint,
...
@@ -115,7 +157,12 @@ func getEphID(id *id.ID, addrSize uint,
jww
.
FATAL
.
Panicf
(
"No ephemeral ids found!"
)
jww
.
FATAL
.
Panicf
(
"No ephemeral ids found!"
)
}
}
return
ephIDs
eIDs
:=
make
([]
ephemeral
.
Id
,
len
(
ephIDs
))
for
i
:=
range
ephIDs
{
eIDs
[
i
]
=
ephIDs
[
i
]
.
Id
}
return
eIDs
}
}
func
getGatewayID
(
ndf
*
ndf
.
NetworkDefinition
)
*
id
.
ID
{
func
getGatewayID
(
ndf
*
ndf
.
NetworkDefinition
)
*
id
.
ID
{
gateways
:=
ndf
.
Gateways
gateways
:=
ndf
.
Gateways
...
...
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