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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
fa6dd8ba
Commit
fa6dd8ba
authored
Jul 29, 2022
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Refactor dumpRounds
parent
08b2f22b
No related branches found
No related tags found
2 merge requests
!510
Release
,
!304
pickup subcommand
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/dumpRounds.go
+104
-84
104 additions, 84 deletions
cmd/dumpRounds.go
with
104 additions
and
84 deletions
cmd/dumpRounds.go
+
104
−
84
View file @
fa6dd8ba
...
@@ -11,16 +11,19 @@ package cmd
...
@@ -11,16 +11,19 @@ package cmd
import
(
import
(
"encoding/base64"
"encoding/base64"
"fmt"
"fmt"
"github.com/spf13/viper"
"strconv"
"strconv"
"time"
"time"
"github.com/spf13/viper"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/xxdk"
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf"
)
)
// dumpRoundsCmd allows the user to view network information about a specific
// dumpRoundsCmd allows the user to view network information about a specific
...
@@ -48,22 +51,22 @@ var dumpRoundsCmd = &cobra.Command{
...
@@ -48,22 +51,22 @@ var dumpRoundsCmd = &cobra.Command{
})
})
waitUntilConnected
(
connected
)
waitUntilConnected
(
connected
)
numRequests
:=
len
(
roundIDs
)
roundInfos
:=
dumpRounds
(
roundIDs
,
user
)
requestCh
:=
make
(
chan
bool
,
numRequests
)
registration
:=
user
.
GetStorage
()
.
GetNDF
()
.
Registration
ndf
:=
user
.
GetStorage
()
.
GetNDF
()
ecp
:=
registration
.
EllipticPubKey
pubkey
,
err
:=
ec
.
LoadPublicKey
(
ecp
)
for
i
:=
range
roundInfos
{
if
err
!=
nil
{
printRoundInfo
(
roundInfos
[
i
])
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
printAndVerifyRoundSig
(
roundInfos
[
i
],
ndf
)
}
},
}
}
fmt
.
Printf
(
"registration pubkey: %s
\n\n
"
,
pubkey
.
MarshalText
())
rcb
:=
func
(
round
rounds
.
Round
,
success
bool
)
{
func
init
()
{
if
!
success
{
rootCmd
.
AddCommand
(
dumpRoundsCmd
)
fmt
.
Printf
(
"round %v lookup failed"
,
round
.
ID
)
}
}
func
printRoundInfo
(
round
rounds
.
Round
)
{
fmt
.
Printf
(
"Round %v:"
,
round
.
ID
)
fmt
.
Printf
(
"Round %v:"
,
round
.
ID
)
fmt
.
Printf
(
"
\n\t
Batch size: %v, State: %v"
,
fmt
.
Printf
(
"
\n\t
Batch size: %v, State: %v"
,
round
.
BatchSize
,
round
.
State
)
round
.
BatchSize
,
round
.
State
)
...
@@ -97,6 +100,16 @@ var dumpRoundsCmd = &cobra.Command{
...
@@ -97,6 +100,16 @@ var dumpRoundsCmd = &cobra.Command{
base64
.
StdEncoding
.
EncodeToString
(
base64
.
StdEncoding
.
EncodeToString
(
ce
.
Source
))
ce
.
Source
))
}
}
}
func
printAndVerifyRoundSig
(
round
rounds
.
Round
,
ndf
*
ndf
.
NetworkDefinition
)
{
registration
:=
ndf
.
Registration
ecp
:=
registration
.
EllipticPubKey
pubkey
,
err
:=
ec
.
LoadPublicKey
(
ecp
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
fmt
.
Printf
(
"registration pubkey: %s
\n\n
"
,
pubkey
.
MarshalText
())
ri
:=
round
.
Raw
ri
:=
round
.
Raw
err
=
signature
.
VerifyEddsa
(
ri
,
pubkey
)
err
=
signature
.
VerifyEddsa
(
ri
,
pubkey
)
...
@@ -118,8 +131,17 @@ var dumpRoundsCmd = &cobra.Command{
...
@@ -118,8 +131,17 @@ var dumpRoundsCmd = &cobra.Command{
// } else {
// } else {
// fmt.Printf("RSA signature succeeded!")
// fmt.Printf("RSA signature succeeded!")
// }
// }
}
func
dumpRounds
(
roundIDs
[]
id
.
Round
,
user
*
xxdk
.
E2e
)
[]
rounds
.
Round
{
numRequests
:=
len
(
roundIDs
)
requestCh
:=
make
(
chan
rounds
.
Round
,
numRequests
)
requestCh
<-
success
rcb
:=
func
(
round
rounds
.
Round
,
success
bool
)
{
if
!
success
{
fmt
.
Printf
(
"round %v lookup failed"
,
round
.
ID
)
}
requestCh
<-
round
}
}
for
i
:=
range
roundIDs
{
for
i
:=
range
roundIDs
{
...
@@ -130,15 +152,13 @@ var dumpRoundsCmd = &cobra.Command{
...
@@ -130,15 +152,13 @@ var dumpRoundsCmd = &cobra.Command{
}
}
}
}
roundInfos
:=
make
([]
rounds
.
Round
,
0
)
for
done
:=
0
;
done
<
numRequests
;
done
++
{
for
done
:=
0
;
done
<
numRequests
;
done
++
{
res
:=
<-
requestCh
res
:=
<-
requestCh
roundInfos
=
append
(
roundInfos
,
res
)
fmt
.
Printf
(
"request complete: %v"
,
res
)
fmt
.
Printf
(
"request complete: %v"
,
res
)
}
}
},
return
roundInfos
}
func
init
()
{
rootCmd
.
AddCommand
(
dumpRoundsCmd
)
}
}
func
parseRoundIDs
(
roundStrs
[]
string
)
[]
id
.
Round
{
func
parseRoundIDs
(
roundStrs
[]
string
)
[]
id
.
Round
{
...
...
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