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

Use the xxmutils restore function to restore contacts from backup

parent d8c47b1c
No related branches found
No related tags found
2 merge requests!231Revert "Update store to print changes to the partners list",!171RestoreContactsFromBackup
...@@ -9,17 +9,18 @@ ...@@ -9,17 +9,18 @@
package cmd package cmd
import ( import (
"encoding/json"
"fmt" "fmt"
"time" "time"
"github.com/spf13/cobra" "github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.com/elixxir/client/bindings"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/single" "gitlab.com/elixxir/client/single"
"gitlab.com/elixxir/client/switchboard" "gitlab.com/elixxir/client/switchboard"
"gitlab.com/elixxir/client/ud" "gitlab.com/elixxir/client/ud"
"gitlab.com/elixxir/client/xxmutils"
"gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/crypto/contact"
"gitlab.com/elixxir/primitives/fact" "gitlab.com/elixxir/primitives/fact"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
...@@ -169,32 +170,18 @@ var udCmd = &cobra.Command{ ...@@ -169,32 +170,18 @@ var udCmd = &cobra.Command{
err.Error()) err.Error())
jww.FATAL.Panicf("BATCHADD: Couldn't read file: %+v", err) jww.FATAL.Panicf("BATCHADD: Couldn't read file: %+v", err)
} }
bindingsClient := bindings.WrapAPIClient(client)
var idList []*id.ID bindingsUdMgr := bindings.WrapUserDiscovery(
err = json.Unmarshal(idListFile, &idList) userDiscoveryMgr)
if err != nil { report, err := xxmutils.RestoreContactsFromBackup(
fmt.Printf("BATCHADD: Couldn't umarshal id list: %s\n", idListFile, bindingsClient, bindingsUdMgr, nil)
err.Error())
jww.FATAL.Panicf("BATCHADD: Couldn't read file: %+v", err)
}
jww.INFO.Printf("BATCHADD: %d IDs: %v", len(idList), idList)
cb := func(newContact contact.Contact, err error) {
if err != nil { if err != nil {
jww.WARN.Printf("BATCHADD: %+v", err) jww.FATAL.Panicf("%+v", err)
return
}
jww.INFO.Printf("BATCHADD: contact %s", newContact)
resetAuthenticatedChannel(client, newContact.ID, newContact)
} }
for i := 0; i < report.LenRestored(); i++ {
userDiscoveryMgr.BatchLookup(idList, cb, 90*time.Second) idBytes := report.GetRestoredAt(i)
uid, _ := id.Unmarshal(idBytes)
for _, uid := range idList { for !client.HasAuthenticatedChannel(uid) {
for client.HasAuthenticatedChannel(uid) == false {
time.Sleep(time.Second) time.Sleep(time.Second)
} }
jww.INFO.Printf("Authenticated channel established for %s", uid) jww.INFO.Printf("Authenticated channel established for %s", uid)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment