Skip to content
Snippets Groups Projects
Commit acda7de7 authored by Josh Brooks's avatar Josh Brooks
Browse files

Remove mnemonic logic from storage package

parent 2ee0156a
No related branches found
No related tags found
2 merge requests!23Release,!19Implement mnemonic in client
package storage
import (
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/netTime"
)
const (
mnemonicKvKey = "mnemonic"
mnemonicKvVersion = 0
mnemonicPath = "/.recovery"
)
func (s *Session) SaveMnemonicInformation(data []byte) error {
s.mnemonicMux.Lock()
defer s.mnemonicMux.Unlock()
vo := &versioned.Object{
Version: mnemonicKvVersion,
Timestamp: netTime.Now(),
Data: data,
}
return s.mnemonicKV.Set(mnemonicKvKey, mnemonicKvVersion, vo)
}
func (s *Session) LoadMnemonicInformation() ([]byte, error) {
s.mux.RLock()
defer s.mux.RUnlock()
vo, err := s.mnemonicKv.Get(mnemonicKvKey, mnemonicKvVersion)
if err != nil {
return nil, err
}
return vo.Data, err
}
...@@ -47,11 +47,8 @@ const currentSessionVersion = 0 ...@@ -47,11 +47,8 @@ const currentSessionVersion = 0
// Session object, backed by encrypted filestore // Session object, backed by encrypted filestore
type Session struct { type Session struct {
kv *versioned.KV kv *versioned.KV
mnemonicKV *versioned.KV
mnemonicKv *versioned.KV
mux sync.RWMutex mux sync.RWMutex
mnemonicMux sync.RWMutex
//memoized data //memoized data
regStatus RegistrationStatus regStatus RegistrationStatus
...@@ -82,16 +79,9 @@ func initStore(baseDir, password string) (*Session, error) { ...@@ -82,16 +79,9 @@ func initStore(baseDir, password string) (*Session, error) {
"Failed to create storage session") "Failed to create storage session")
} }
// Create a separate file store system for account recovery
mnemonicFS, err := ekv.NewFilestore(baseDir+mnemonicPath, password)
if err != nil {
return nil, errors.WithMessage(err,
"Failed to create mnemonic store")
}
s = &Session{ s = &Session{
kv: versioned.NewKV(fs), kv: versioned.NewKV(fs),
mnemonicKV: versioned.NewKV(mnemonicFS),
} }
return s, nil return s, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment