Skip to content
Snippets Groups Projects
Commit 81294f9d authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Formatted output for dump rounds

parent 571502d8
No related branches found
No related tags found
2 merge requests!510Release,!261Add dumprounds
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
package cmd package cmd
import ( import (
"encoding/base64"
"fmt" "fmt"
"strconv" "strconv"
"time" "time"
...@@ -21,8 +22,8 @@ import ( ...@@ -21,8 +22,8 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
) )
// singleCmd is the single-use subcommand that allows for sending and responding // dumpRoundsCmd allows the user to view network information about a specific
// to single-use messages. // round on the network.
var dumpRoundsCmd = &cobra.Command{ var dumpRoundsCmd = &cobra.Command{
Use: "dumprounds", Use: "dumprounds",
Short: "Dump round information for specified rounds", Short: "Dump round information for specified rounds",
...@@ -32,13 +33,11 @@ var dumpRoundsCmd = &cobra.Command{ ...@@ -32,13 +33,11 @@ var dumpRoundsCmd = &cobra.Command{
cmixParams, e2eParams := initParams() cmixParams, e2eParams := initParams()
client := initE2e(cmixParams, e2eParams) client := initE2e(cmixParams, e2eParams)
err := client.StartNetworkFollower(5 * time.Second) err := client.StartNetworkFollower(5 * time.Second)
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
// Wait until connected or crash on timeout
connected := make(chan bool, 10) connected := make(chan bool, 10)
client.GetCmix().AddHealthCallback( client.GetCmix().AddHealthCallback(
func(isconnected bool) { func(isconnected bool) {
...@@ -49,24 +48,74 @@ var dumpRoundsCmd = &cobra.Command{ ...@@ -49,24 +48,74 @@ var dumpRoundsCmd = &cobra.Command{
numRequests := len(roundIDs) numRequests := len(roundIDs)
requestCh := make(chan bool, numRequests) requestCh := make(chan bool, numRequests)
ecp := client.GetStorage().GetNDF().Registration.EllipticPubKey registration := client.GetStorage().GetNDF().Registration
fmt.Printf("pubkey: %s\n\n", ecp) ecp := registration.EllipticPubKey
pubkey, err := ec.LoadPublicKey(ecp) pubkey, err := ec.LoadPublicKey(ecp)
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
fmt.Printf("registration pubkey: %s\n\n", pubkey.MarshalText())
fmt.Printf("pubkey unserialized: %s\n\n", pubkey.MarshalText())
rcb := func(round rounds.Round, success bool) { rcb := func(round rounds.Round, success bool) {
fmt.Printf("Lookup for %v: %v\n\n", round.ID, success) if !success {
fmt.Printf("Info: %v\n\n", round) fmt.Printf("round %v lookup failed", round.ID)
}
fmt.Printf("Round %v:", round.ID)
fmt.Printf("\n\tBatch size: %v, State: %v",
round.BatchSize, round.State)
fmt.Printf("\n\tUpdateID: %v, AddrSpaceSize: %v",
round.UpdateID, round.AddressSpaceSize)
fmt.Printf("\n\tTopology: ")
for i, nodeId := range round.Raw.Topology {
nidStr := base64.StdEncoding.EncodeToString(
nodeId)
fmt.Printf("\n\t\t%d\t-\t%s", i, nidStr)
}
fmt.Printf("\n\tTimestamps: ")
for state, ts := range round.Timestamps {
fmt.Printf("\n\t\t%v \t-\t%v", state, ts)
}
fmt.Printf("\n\tErrors (%d): ", len(round.Raw.Errors))
for i, err := range round.Raw.Errors {
fmt.Printf("\n\t\t%d - %v", i, err)
}
fmt.Printf("\n\tClientErrors (%d): ",
len(round.Raw.ClientErrors))
for _, ce := range round.Raw.ClientErrors {
fmt.Printf("\n\t\t%s - %v, Src: %v",
base64.StdEncoding.EncodeToString(
ce.ClientId),
ce.Error,
base64.StdEncoding.EncodeToString(
ce.Source))
}
ri := round.Raw ri := round.Raw
err = signature.VerifyEddsa(ri, pubkey) err = signature.VerifyEddsa(ri, pubkey)
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) fmt.Printf("\n\tECC signature failed: %v", err)
fmt.Printf("\n\tuse trace logging for sig details")
} else {
fmt.Printf("\n\tECC signature succeeded!\n\n")
} }
// fmt.Printf("Round Info RAW: %v\n\n", round)
// rsapubkey, _ := rsa.LoadPublicKeyFromPem([]byte(
// registration.TlsCertificate))
// signature.VerifyRsa(ri, rsapubkey)
// if err != nil {
// fmt.Printf("RSA signature failed: %v", err)
// fmt.Printf("use trace logging for sig details")
// } else {
// fmt.Printf("RSA signature succeeded!")
// }
requestCh <- success requestCh <- success
} }
......
package rounds package rounds
import ( import (
"fmt"
"time"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
pb "gitlab.com/elixxir/comms/mixmessages" pb "gitlab.com/elixxir/comms/mixmessages"
"gitlab.com/elixxir/primitives/states" "gitlab.com/elixxir/primitives/states"
"gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"time"
) )
type Round struct { type Round struct {
...@@ -127,3 +129,9 @@ func (r Round) GetEndTimestamp() time.Time { ...@@ -127,3 +129,9 @@ func (r Round) GetEndTimestamp() time.Time {
// Unreachable // Unreachable
return time.Time{} return time.Time{}
} }
// String prints a formatted version of the client error string
func (re *RoundError) String() string {
return fmt.Sprintf("ClientError(ClientID: %s, Err: %s)",
re.NodeID, re.Error)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment