Skip to content
Snippets Groups Projects
Commit 1db703a9 authored by Jake Taylor's avatar Jake Taylor
Browse files

added mutex to pushnodekey

parent e8220488
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"gitlab.com/elixxir/ekv" "gitlab.com/elixxir/ekv"
"gitlab.com/xx_network/comms/connect" "gitlab.com/xx_network/comms/connect"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"sync"
"testing" "testing"
"time" "time"
) )
...@@ -23,6 +24,7 @@ import ( ...@@ -23,6 +24,7 @@ import (
// Session object, backed by encrypted filestore // Session object, backed by encrypted filestore
type Session struct { type Session struct {
kv *VersionedKV kv *VersionedKV
mux sync.Mutex
} }
// Initialize a new Session object // Initialize a new Session object
...@@ -137,6 +139,10 @@ func (s *Session) GetNodeKeysFromCircuit(topology *connect.Circuit) ( ...@@ -137,6 +139,10 @@ func (s *Session) GetNodeKeysFromCircuit(topology *connect.Circuit) (
// Set NodeKeys in the Session // Set NodeKeys in the Session
func (s *Session) PushNodeKey(id *id.ID, key user.NodeKeys) error { func (s *Session) PushNodeKey(id *id.ID, key user.NodeKeys) error {
// Thread-safety
s.mux.Lock()
defer s.mux.Unlock()
// Obtain NodeKeys map // Obtain NodeKeys map
nodeKeys, err := s.GetNodeKeys() nodeKeys, err := s.GetNodeKeys()
if err != nil { if err != nil {
...@@ -180,6 +186,6 @@ func InitTestingSession(i interface{}) *Session { ...@@ -180,6 +186,6 @@ func InitTestingSession(i interface{}) *Session {
} }
store := make(ekv.Memstore) store := make(ekv.Memstore)
return &Session{NewVersionedKV(store)} return &Session{kv: NewVersionedKV(store)}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment