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
28794268
Commit
28794268
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
prelim pickup subcommand
parent
250f2fb5
No related branches found
No related tags found
2 merge requests
!510
Release
,
!304
pickup subcommand
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/dumpRounds.go
+1
-1
1 addition, 1 deletion
cmd/dumpRounds.go
cmd/flags.go
+4
-0
4 additions, 0 deletions
cmd/flags.go
cmd/pickup.go
+168
-0
168 additions, 0 deletions
cmd/pickup.go
with
173 additions
and
1 deletion
cmd/dumpRounds.go
+
1
−
1
View file @
28794268
...
...
@@ -156,7 +156,7 @@ func dumpRounds(roundIDs []id.Round, user *xxdk.E2e) []rounds.Round {
for
done
:=
0
;
done
<
numRequests
;
done
++
{
res
:=
<-
requestCh
roundInfos
=
append
(
roundInfos
,
res
)
fmt
.
Printf
(
"request complete: %v"
,
res
)
jww
.
DEBUG
.
Printf
(
"request complete: %v"
,
res
)
}
return
roundInfos
}
...
...
This diff is collapsed.
Click to expand it.
cmd/flags.go
+
4
−
0
View file @
28794268
...
...
@@ -148,4 +148,8 @@ const (
udSearchEmailFlag
=
"searchemail"
udSearchPhoneFlag
=
"searchphone"
udBatchAddFlag
=
"batchadd"
///////////////// pickup subcommand flags //////////////////////////////
pickupGW
=
"gateway"
pickupID
=
"id"
)
This diff is collapsed.
Click to expand it.
cmd/pickup.go
0 → 100644
+
168
−
0
View file @
28794268
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
// Package cmd initializes the CLI and config parsers as well as the logger.
package
cmd
import
(
"fmt"
"time"
"github.com/pkg/errors"
"github.com/spf13/cobra"
jww
"github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"gitlab.com/elixxir/client/cmix/pickup"
pb
"gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/primitives/states"
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/crypto/randomness"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/ndf"
)
// pickupCmd allows the user to view network information about a specific
// round on the network.
var
pickupCmd
=
&
cobra
.
Command
{
Use
:
"pickup"
,
Short
:
"Download the bloomfilter and messages for a round"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
roundIDs
:=
parseRoundIDs
(
args
)
cmixParams
,
e2eParams
:=
initParams
()
authCbs
:=
makeAuthCallbacks
(
viper
.
GetBool
(
unsafeChannelCreationFlag
),
e2eParams
)
user
:=
initE2e
(
cmixParams
,
e2eParams
,
authCbs
)
err
:=
user
.
StartNetworkFollower
(
5
*
time
.
Second
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
connected
:=
make
(
chan
bool
,
10
)
user
.
GetCmix
()
.
AddHealthCallback
(
func
(
isconnected
bool
)
{
connected
<-
isconnected
})
waitUntilConnected
(
connected
)
ndf
:=
user
.
GetStorage
()
.
GetNDF
()
gwID
:=
getGatewayID
(
ndf
)
clientID
:=
parseRecipient
(
viper
.
GetString
(
pickupID
))
// First we get round info, then we use the timestamps to
// calculate the right ephID and retrieve the right bloom filter
roundInfos
:=
dumpRounds
(
roundIDs
,
user
)
for
i
:=
range
roundInfos
{
ri
:=
roundInfos
[
i
]
ephIDs
:=
getEphID
(
clientID
,
uint
(
ri
.
AddressSpaceSize
),
ri
.
Timestamps
[
states
.
QUEUED
])
for
j
:=
range
ephIDs
{
ephID
:=
ephIDs
[
j
]
fmt
.
Printf
(
"Getting messages for %s, %d
\n
"
,
ri
.
ID
,
ephID
.
Id
.
Int64
())
msgRsp
,
err
:=
getMessagesFromRound
(
gwID
,
ri
.
ID
,
ephID
.
Id
,
user
.
GetComms
())
if
err
!=
nil
{
fmt
.
Printf
(
"
\n\n
round pickup: %+v
\n\n
"
,
err
)
}
fmt
.
Printf
(
"=====ROUNDPICKUP=====
\n\n
%+v
\n\n\n
"
,
msgRsp
)
fmt
.
Printf
(
"%d messages for user %d"
,
len
(
msgRsp
.
Messages
),
ephIDs
)
for
k
:=
range
msgRsp
.
Messages
{
fmt
.
Printf
(
"%v
\n
"
,
msgRsp
.
Messages
[
k
]
.
PayloadA
)
}
}
}
},
}
func
init
()
{
pickupCmd
.
Flags
()
.
StringP
(
pickupGW
,
"g"
,
""
,
"gateway (base64 address string) to download from"
)
bindFlagHelper
(
pickupGW
,
pickupCmd
)
pickupCmd
.
Flags
()
.
StringP
(
pickupID
,
"i"
,
""
,
"id to check"
)
bindFlagHelper
(
pickupID
,
pickupCmd
)
rootCmd
.
AddCommand
(
pickupCmd
)
}
func
getEphID
(
id
*
id
.
ID
,
addrSize
uint
,
roundStart
time
.
Time
)
[]
ephemeral
.
ProtoIdentity
{
fmt
.
Printf
(
"Getting EphIDs for %s"
,
roundStart
)
ephIDs
,
err
:=
ephemeral
.
GetIdsByRange
(
id
,
addrSize
,
roundStart
,
time
.
Duration
(
12
*
time
.
Hour
))
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
if
len
(
ephIDs
)
==
0
{
jww
.
FATAL
.
Panicf
(
"No ephemeral ids found!"
)
}
return
ephIDs
}
func
getGatewayID
(
ndf
*
ndf
.
NetworkDefinition
)
*
id
.
ID
{
gateways
:=
ndf
.
Gateways
gwID
:=
viper
.
GetString
(
pickupGW
)
if
gwID
==
""
{
rng
:=
csprng
.
NewSystemRNG
()
i
:=
randomness
.
ReadRangeUint32
(
0
,
uint32
(
len
(
gateways
)),
rng
)
id
,
err
:=
id
.
Unmarshal
([]
byte
(
gateways
[
i
]
.
ID
))
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
fmt
.
Printf
(
"selected random gw: %s
\n
"
,
id
)
return
id
}
for
i
:=
range
gateways
{
curID
,
_
:=
id
.
Unmarshal
(
gateways
[
i
]
.
ID
)
jww
.
DEBUG
.
Printf
(
"%s ==? %s"
,
gwID
,
curID
)
if
curID
.
String
()
==
gwID
{
return
curID
}
}
jww
.
FATAL
.
Panicf
(
"%s is not a gateway in the NDF"
,
gwID
)
return
nil
}
func
getBloomFilter
(
targetGW
string
,
ephID
int64
)
*
pb
.
ClientBlooms
{
return
nil
}
func
getMessagesFromRound
(
targetGW
*
id
.
ID
,
roundID
id
.
Round
,
ephID
ephemeral
.
Id
,
comms
pickup
.
MessageRetrievalComms
)
(
*
pb
.
GetMessagesResponse
,
error
)
{
host
,
ok
:=
comms
.
GetHost
(
targetGW
)
if
!
ok
{
return
nil
,
errors
.
Errorf
(
"can't find host %s"
,
targetGW
)
}
msgReq
:=
&
pb
.
GetMessages
{
ClientID
:
ephID
[
:
],
RoundID
:
uint64
(
roundID
),
Target
:
targetGW
.
Marshal
(),
}
jww
.
DEBUG
.
Printf
(
"Sending request: %+v"
,
msgReq
)
return
comms
.
RequestMessages
(
host
,
msgReq
)
}
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