Skip to content

Commit

Permalink
fixing key deletion routine
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo committed Jun 27, 2019
1 parent 4825795 commit 2602652
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (client *Node) SaveConfigKeys() error {
if serverConfig == nil {
return fmt.Errorf("error encoding keys: server config not found")
}
serverConfig.Keys = make([]*config.KeyConfig, 0)
for _, key := range server.keys {
keyShareBytes, err := message.EncodeKeyShare(key.Share)
if err != nil {
Expand All @@ -164,14 +165,11 @@ func (client *Node) SaveConfigKeys() error {
}
keyShareB64 := base64.StdEncoding.EncodeToString(keyShareBytes)
keyMetaB64 := base64.StdEncoding.EncodeToString(keyMetaBytes)
keyConfig := serverConfig.GetKeyByID(key.ID)
if keyConfig == nil {
serverConfig.Keys = append(serverConfig.Keys, &config.KeyConfig{
ID: key.ID,
KeyMetaInfo: keyMetaB64,
KeyShare: keyShareB64,
})
}
serverConfig.Keys = append(serverConfig.Keys, &config.KeyConfig{
ID: key.ID,
KeyMetaInfo: keyMetaB64,
KeyShare: keyShareB64,
})
}
}
viper.Set("config", client.config)
Expand Down

0 comments on commit 2602652

Please sign in to comment.