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

debugging comments

parent 3704287c
Branches
Tags
3 merge requests!510Release,!267Make BuildReceptionIdentity public, and make backup restore function return a...,!263Hotfix/refactor cmd
......@@ -11,6 +11,7 @@ package backup
import (
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/rekey"
"gitlab.com/elixxir/client/storage"
......@@ -38,6 +39,9 @@ func NewClientFromBackup(ndfJSON, storageDir string, sessionPassword,
"Failed to unmarshal decrypted client contents.")
}
jww.INFO.Printf("Decrypted backup ID to Restore: %v",
backUp.ReceptionIdentity.ComputedID)
usr := user.NewUserFromBackup(backUp)
def, err := xxdk.ParseNDF(ndfJSON)
......
......
......@@ -596,6 +596,7 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
pass, regCode, userIDprefix)
} else if backupPath != "" {
jww.INFO.Printf("Restoring user from %s", backupPath)
b, backupFile := loadBackup(backupPath, string(backupPass))
// Marshal the backup object in JSON
......@@ -619,6 +620,8 @@ func initCmix() (*xxdk.Cmix, xxdk.ReceptionIdentity) {
jww.FATAL.Panicf("%+v", err)
}
jww.INFO.Printf("User Restored: %v", knownReception.ID)
backupIdListPath := viper.GetString("backupIdList")
if backupIdListPath != "" {
// Marshal backed up ID list to JSON
......
......
......@@ -39,38 +39,16 @@ var udCmd = &cobra.Command{
// get user and save contact to file
user := client.GetReceptionIdentity()
jww.INFO.Printf("User: %s", user.ID)
jww.INFO.Printf("[UD]User: %s", user.ID)
writeContact(user.GetContact())
// // Set up reception handler
// swBoard := client.GetSwitchboard()
// recvCh := make(chan message.Receive, 10000)
// listenerID := swBoard.RegisterChannel("DefaultCLIReceiver",
// switchboard.AnyUser(), message.XxMessage, recvCh)
// jww.INFO.Printf("Message ListenerID: %v", listenerID)
// // Set up auth request handler, which simply prints the user ID of the
// // requester
// authMgr := client.GetAuthRegistrar()
// authMgr.AddGeneralRequestCallback(printChanRequest)
// // If unsafe channels, add auto-acceptor
// if viper.GetBool("unsafe-channel-creation") {
// authMgr.AddGeneralRequestCallback(func(
// requester contact.Contact) {
// jww.INFO.Printf("Got Request: %s", requester.ID)
// _, err := client.ConfirmAuthenticatedChannel(requester)
// if err != nil {
// jww.FATAL.Panicf("%+v", err)
// }
// })
// }
err := client.StartNetworkFollower(50 * time.Millisecond)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
jww.TRACE.Printf("[UD] Waiting for connection...")
// Wait until connected or crash on timeout
connected := make(chan bool, 10)
client.GetCmix().AddHealthCallback(
......@@ -79,9 +57,12 @@ var udCmd = &cobra.Command{
})
waitUntilConnected(connected)
jww.TRACE.Printf("[UD] Connected!")
// Make user discovery manager
rng := client.GetRng()
userToRegister := viper.GetString("register")
jww.TRACE.Printf("[UD] Registering user %v...", userToRegister)
userDiscoveryMgr, err := ud.NewManager(client, client.GetComms(),
client.NetworkFollowerStatus, userToRegister, nil)
if err != nil {
......@@ -95,6 +76,7 @@ var udCmd = &cobra.Command{
}
}
jww.INFO.Printf("[UD] Registered user %v", userToRegister)
var newFacts fact.FactList
phone := viper.GetString("addphone")
......@@ -116,24 +98,29 @@ var udCmd = &cobra.Command{
}
for i := 0; i < len(newFacts); i++ {
jww.INFO.Printf("[UD] Registering Fact: %v",
newFacts[i])
r, err := userDiscoveryMgr.SendRegisterFact(newFacts[i])
if err != nil {
fmt.Printf("Failed to register fact: %s\n",
newFacts[i])
jww.FATAL.Panicf("Failed to send register fact: %+v", err)
jww.FATAL.Panicf("[UD] Failed to send register fact: %+v", err)
}
// TODO Store the code?
jww.INFO.Printf("Fact Add Response: %+v", r)
jww.INFO.Printf("[UD] Fact Add Response: %+v", r)
}
confirmID := viper.GetString("confirm")
if confirmID != "" {
jww.INFO.Printf("[UD] Confirming fact: %v", confirmID)
err = userDiscoveryMgr.ConfirmFact(confirmID, confirmID)
if err != nil {
fmt.Printf("Couldn't confirm fact: %s\n",
err.Error())
jww.FATAL.Panicf("%+v", err)
}
jww.INFO.Printf("[UD] Confirmed %v", confirmID)
}
udContact, err := userDiscoveryMgr.GetContact()
......@@ -147,9 +134,7 @@ var udCmd = &cobra.Command{
lookupIDStr := viper.GetString("lookup")
if lookupIDStr != "" {
lookupID := parseRecipient(lookupIDStr)
//if !ok {
// jww.FATAL.Panicf("Could not parse recipient: %s", lookupIDStr)
//}
jww.INFO.Printf("[UD] Looking up %v", lookupID)
cb := func(newContact contact.Contact, err error) {
if err != nil {
......@@ -177,7 +162,7 @@ var udCmd = &cobra.Command{
err.Error())
jww.FATAL.Panicf("BATCHADD: Couldn't read file: %+v", err)
}
jww.INFO.Printf("BATCHADD: Running")
jww.INFO.Printf("[UD] BATCHADD: Running")
restored, _, _, err := xxmutils.RestoreContactsFromBackup(
idListFile, client, userDiscoveryMgr, nil)
if err != nil {
......@@ -188,7 +173,7 @@ var udCmd = &cobra.Command{
for !client.GetE2E().HasAuthenticatedChannel(uid) {
time.Sleep(time.Second)
}
jww.INFO.Printf("Authenticated channel established for %s", uid)
jww.INFO.Printf("[UD] Authenticated channel established for %s", uid)
}
}
usernameSearchStr := viper.GetString("searchusername")
......@@ -233,7 +218,7 @@ var udCmd = &cobra.Command{
"Failed to remove user %s: %+v",
userToRemove, err)
}
fmt.Printf("Removed user from discovery: %s\n",
fmt.Printf("[UD] Removed user from discovery: %s\n",
userToRemove)
}
......@@ -256,6 +241,7 @@ var udCmd = &cobra.Command{
stream := rng.GetStream()
defer stream.Close()
jww.INFO.Printf("[UD] Search: %v", facts)
_, _, err = ud.Search(client.GetCmix(),
client.GetEventReporter(),
stream, client.GetE2E().GetGroup(),
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment