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
571502d8
Commit
571502d8
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Add util function to dump historical round info and check the signature
parent
3ebd3c1f
No related branches found
No related tags found
2 merge requests
!510
Release
,
!261
Add dumprounds
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/dumpRounds.go
+108
-0
108 additions, 0 deletions
cmd/dumpRounds.go
with
108 additions
and
0 deletions
cmd/dumpRounds.go
0 → 100644
+
108
−
0
View file @
571502d8
///////////////////////////////////////////////////////////////////////////////
// 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"
"strconv"
"time"
"github.com/spf13/cobra"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/primitives/id"
)
// singleCmd is the single-use subcommand that allows for sending and responding
// to single-use messages.
var
dumpRoundsCmd
=
&
cobra
.
Command
{
Use
:
"dumprounds"
,
Short
:
"Dump round information for specified rounds"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
roundIDs
:=
parseRoundIDs
(
args
)
cmixParams
,
e2eParams
:=
initParams
()
client
:=
initE2e
(
cmixParams
,
e2eParams
)
err
:=
client
.
StartNetworkFollower
(
5
*
time
.
Second
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
// Wait until connected or crash on timeout
connected
:=
make
(
chan
bool
,
10
)
client
.
GetCmix
()
.
AddHealthCallback
(
func
(
isconnected
bool
)
{
connected
<-
isconnected
})
waitUntilConnected
(
connected
)
numRequests
:=
len
(
roundIDs
)
requestCh
:=
make
(
chan
bool
,
numRequests
)
ecp
:=
client
.
GetStorage
()
.
GetNDF
()
.
Registration
.
EllipticPubKey
fmt
.
Printf
(
"pubkey: %s
\n\n
"
,
ecp
)
pubkey
,
err
:=
ec
.
LoadPublicKey
(
ecp
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
fmt
.
Printf
(
"pubkey unserialized: %s
\n\n
"
,
pubkey
.
MarshalText
())
rcb
:=
func
(
round
rounds
.
Round
,
success
bool
)
{
fmt
.
Printf
(
"Lookup for %v: %v
\n\n
"
,
round
.
ID
,
success
)
fmt
.
Printf
(
"Info: %v
\n\n
"
,
round
)
ri
:=
round
.
Raw
err
=
signature
.
VerifyEddsa
(
ri
,
pubkey
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
requestCh
<-
success
}
for
i
:=
range
roundIDs
{
rid
:=
roundIDs
[
i
]
err
:=
client
.
GetCmix
()
.
LookupHistoricalRound
(
rid
,
rcb
)
if
err
!=
nil
{
fmt
.
Printf
(
"error on %v: %v"
,
rid
,
err
)
}
}
for
done
:=
0
;
done
<
numRequests
;
done
++
{
res
:=
<-
requestCh
fmt
.
Printf
(
"request complete: %v"
,
res
)
}
},
}
func
init
()
{
rootCmd
.
AddCommand
(
dumpRoundsCmd
)
}
func
parseRoundIDs
(
roundStrs
[]
string
)
[]
id
.
Round
{
var
roundIDs
[]
id
.
Round
for
_
,
r
:=
range
roundStrs
{
i
,
err
:=
parseRoundID
(
r
)
if
err
!=
nil
{
fmt
.
Printf
(
"Could not parse into round ID: %s, %v"
,
r
,
err
)
}
else
{
roundIDs
=
append
(
roundIDs
,
id
.
Round
(
i
))
}
}
return
roundIDs
}
func
parseRoundID
(
roundStr
string
)
(
uint64
,
error
)
{
return
strconv
.
ParseUint
(
roundStr
,
10
,
64
)
}
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