From 2602652f1dc16b3d2588cd176622c5aefbb4969e Mon Sep 17 00:00:00 2001 From: Eduardo Date: Thu, 27 Jun 2019 19:58:35 -0400 Subject: [PATCH] fixing key deletion routine --- node.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/node.go b/node.go index 7976d41..6523b3f 100644 --- a/node.go +++ b/node.go @@ -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 { @@ -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)