diff --git a/go.mod b/go.mod index deaa53cd4a7358d2952e01ae2ee7871b888919fc..cef9d933d99f773ed547b364048c4eeb0f0676d0 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.6.2 - gitlab.com/elixxir/comms v0.0.0-20200827170208-d1f872422b7e + gitlab.com/elixxir/comms v0.0.0-20200827193018-c0911a1a1ec0 gitlab.com/elixxir/crypto v0.0.0-20200827170914-14227f20900c gitlab.com/elixxir/ekv v0.0.0-20200729182028-159355ea5842 gitlab.com/elixxir/primitives v0.0.0-20200827170420-5d50351f99b4 diff --git a/go.sum b/go.sum index 82f8a662ac7c0046625f9e8c364c386ed5587c10..68abff067eb5ba644dd31a5bfedee520660bc210 100644 --- a/go.sum +++ b/go.sum @@ -169,6 +169,8 @@ gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8 h1:6kwb++vm3XUf+AoR1 gitlab.com/elixxir/comms v0.0.0-20200825195434-49150e0605d8/go.mod h1:HW3Ige10aeJeyb2fcQ/YOBPiyzY/4jHau1Cj6/1WBHc= gitlab.com/elixxir/comms v0.0.0-20200827170208-d1f872422b7e h1:BEBxLOW6yMdT53rBvxlDifsGSPYKA88K233DOpKY5Zw= gitlab.com/elixxir/comms v0.0.0-20200827170208-d1f872422b7e/go.mod h1:HW3Ige10aeJeyb2fcQ/YOBPiyzY/4jHau1Cj6/1WBHc= +gitlab.com/elixxir/comms v0.0.0-20200827193018-c0911a1a1ec0 h1:C0P5VqrgGcTuV9kCicxakHLSUFN3qNk55O/nrBmY0fk= +gitlab.com/elixxir/comms v0.0.0-20200827193018-c0911a1a1ec0/go.mod h1:HW3Ige10aeJeyb2fcQ/YOBPiyzY/4jHau1Cj6/1WBHc= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4 h1:28ftZDeYEko7xptCZzeFWS1Iam95dj46TWFVVlKmw6A= gitlab.com/elixxir/crypto v0.0.0-20200804182833-984246dea2c4/go.mod h1:ucm9SFKJo+K0N2GwRRpaNr+tKXMIOVWzmyUD0SbOu2c= gitlab.com/elixxir/crypto v0.0.0-20200805174804-bdf909f2a16d/go.mod h1:cu6uNoANVLV0J6HyTL6KqVtVyh9SHU1RjJhytYlsbVQ= diff --git a/io/threads.go b/io/threads.go index 6713e3a86eb0a73f2416f8e3cb8211e2acd8be2d..98d0d43a0c23709608158a01785f8b6436c89d84 100644 --- a/io/threads.go +++ b/io/threads.go @@ -1,5 +1,5 @@ //////////////////////////////////////////////////////////////////////////////// -// Copyright © 2019 Privategrity Corporation / +// Copyright © 2020 Privategrity Corporation / // / // All rights reserved. / //////////////////////////////////////////////////////////////////////////////// @@ -30,7 +30,7 @@ func (c ChanStop) Close(timeout time.Duration) { select { case <-timer: jww.ERROR.Printf("goroutine failed to Close: %s", c.name) - case <- c.quit: + case <-c.quit: return } } @@ -39,14 +39,13 @@ func (c ChanStop) Close(timeout time.Duration) { // structure func StartTrackNetwork(ctx *context.Context) Stoppable { stopper := ChanStop{ - name: "TrackNetwork" + name: "TrackNetwork", quit: make(chan bool), } go TrackNetwork(ctx, stopper.quit) return stopper } - // TrackNetwork polls the network to get updated on the state of nodes, the // round status, and informs the client when messages can be retrieved. func TrackNetwork(ctx *context.Context, quitCh chan bool) { @@ -96,7 +95,7 @@ func trackNetwork(ctx) { func StartProcessHistoricalRounds(ctx *context.Context) Stoppable { stopper := ChanStop{ - name: "ProcessHistoricalRounds" + name: "ProcessHistoricalRounds", quit: make(chan bool), } go ProcessHistoricalRounds(ctx, stopper.quit) @@ -165,7 +164,7 @@ func MessageReceiver(ctx *context.Context, messagesCh chan ClientMessage, select { case <-quitCh: done = true - case m := <- messagesCh: + case m := <-messagesCh: ReceiveMessage(ctx, m) // defined elsewhere... } } @@ -173,7 +172,7 @@ func MessageReceiver(ctx *context.Context, messagesCh chan ClientMessage, func StartNodeKeyExchange(ctx *context.Context) { keyCh := ctx.GetNetwork().GetNodeKeysCh() - for i := 0; i < ctx.GetNumNodeKeyExchangers(); i ++ { + for i := 0; i < ctx.GetNumNodeKeyExchangers(); i++ { // quitCh created for each thread, add to multistop quitCh := make(chan bool) go ExchangeNodeKeys(ctx, keyCh, quitCh) @@ -188,7 +187,7 @@ func ExchangeNodeKeys(ctx *context.Context, keyCh chan node.ID, quitCh chan bool select { case <-quitCh: done = true - case nid := <- keyCh: + case nid := <-keyCh: nodekey := RegisterNode(ctx, nid) // defined elsewhere... ctx.GetStorage().SetNodeKey(nid, nodekey) } @@ -197,7 +196,7 @@ func ExchangeNodeKeys(ctx *context.Context, keyCh chan node.ID, quitCh chan bool func StartNodeRemover(ctx *context.Context) { remCh := ctx.GetNetwork().GetNodeRemCh() - for i := 0; i < ctx.GetNumNodeRemovers(); i ++ { + for i := 0; i < ctx.GetNumNodeRemovers(); i++ { // quitCh created for each thread, add to multistop quitCh := make(chan bool) go RemoveNode(ctx, remCh, quitCh) @@ -212,9 +211,8 @@ func RemoveNode(ctx *context.Context, remCh chan node.ID, quitCh chan bool) { select { case <-quitCh: done = true - case nid := <- keyCh: + case nid := <-keyCh: ctx.GetStorage().RemoveNodeKey(nid) } } } - diff --git a/storage/cmix/store.go b/storage/cmix/store.go index 9a3b4c96b71d4abd0ad5b5005a5d619338860d42..069de5f97e69c1506d8138ab23fb66315f01d148 100644 --- a/storage/cmix/store.go +++ b/storage/cmix/store.go @@ -108,9 +108,8 @@ func (s *Store) Add(nid *id.ID, k *cyclic.Int) error { return s.save() } -// removes the key from the cmix storage object. Saves an updates node list to -// -func (s *Store) Remove(nid *id.ID, k *cyclic.Int) error { +// Remove a Node key from the nodes map and save +func (s *Store) Remove(nid *id.ID) error { s.mux.Lock() defer s.mux.Unlock() @@ -126,7 +125,7 @@ func (s *Store) Remove(nid *id.ID, k *cyclic.Int) error { delete(s.nodes, *nid) - return nil + return s.save() } //Returns a RoundKeys for the topology and a list of nodes it did not have a key for diff --git a/storage/e2e/key_test.go b/storage/e2e/key_test.go index 78220af85ea13d368cac9c410d2b551040860cd9..808546eeb25a5d3c6cc4289746a2741c444ed1b8 100644 --- a/storage/e2e/key_test.go +++ b/storage/e2e/key_test.go @@ -1,3 +1,9 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 Privategrity Corporation / +// / +// All rights reserved. / +//////////////////////////////////////////////////////////////////////////////// + package e2e import ( @@ -208,8 +214,8 @@ func getSession(t *testing.T) *Session { manager: &Manager{ ctx: ctx, }, - baseKey: baseKey, - keyState: keyState, + baseKey: baseKey, + keyState: keyState, } } diff --git a/storage/e2e/params.go b/storage/e2e/params.go index 93fcea60e8a6676f69e36492bb7c4ad6e30b54d0..f9672c636857cef651599f2a6f6a9e4bc042591c 100644 --- a/storage/e2e/params.go +++ b/storage/e2e/params.go @@ -1,3 +1,9 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 Privategrity Corporation / +// / +// All rights reserved. / +//////////////////////////////////////////////////////////////////////////////// + package e2e import "gitlab.com/elixxir/crypto/e2e" @@ -37,4 +43,4 @@ func GetDefaultSessionParams() SessionParams { MinNumKeys: threshold, }, } -} \ No newline at end of file +} diff --git a/storage/e2e/sessionBuff.go b/storage/e2e/sessionBuff.go index 523b5e6f4a1b635149a6e6a6e4bcd1166f705d2c..c2821ad0d63ab95c5a0ec2182f0e7fbea7838af5 100644 --- a/storage/e2e/sessionBuff.go +++ b/storage/e2e/sessionBuff.go @@ -1,3 +1,9 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 Privategrity Corporation / +// / +// All rights reserved. / +//////////////////////////////////////////////////////////////////////////////// + package e2e import ( @@ -253,4 +259,4 @@ func (sb *sessionBuff) clean() error { func makeSessionBuffKey(keyPrefix string, partnerID *id.ID) string { return keyPrefix + "sessionBuffer" + base64.StdEncoding.EncodeToString(partnerID.Marshal()) -} \ No newline at end of file +} diff --git a/storage/e2e/store.go b/storage/e2e/store.go index 964f88e251c72d89b4f3ecfb08788bf0a74680b0..dac6ec27090b039b06c2e754fd341c7efb1c5c9d 100644 --- a/storage/e2e/store.go +++ b/storage/e2e/store.go @@ -1,3 +1,9 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 Privategrity Corporation / +// / +// All rights reserved. / +//////////////////////////////////////////////////////////////////////////////// + package e2e import ( @@ -14,7 +20,6 @@ import ( "time" ) - const currentStoreVersion = 0 const storeKey = "e2eKeyStore" const pubKeyKey = "e2eDhPubKey" @@ -277,4 +282,3 @@ func (f *fingerprints) Pop(fingerprint format.Fingerprint) (*Key, error) { return key, nil } - diff --git a/storage/regStatus.go b/storage/regStatus.go index 28f55a99e15919ea755bf1319204aa402b3e651b..b065e450a1389b513a33df004123b38f62bc2e54 100644 --- a/storage/regStatus.go +++ b/storage/regStatus.go @@ -1,3 +1,9 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright © 2020 Privategrity Corporation / +// / +// All rights reserved. / +//////////////////////////////////////////////////////////////////////////////// + package storage import ( @@ -101,4 +107,4 @@ func (s *Session) GetRegistrationStatus() RegistrationStatus { s.mux.RLock() defer s.mux.RUnlock() return s.regStatus -} \ No newline at end of file +} diff --git a/storage/session.go b/storage/session.go index ad4569f35975e7d45af6484db6b59c822f9bd778..497df93cca1c392f9ec10d3d08b753b52d952046 100644 --- a/storage/session.go +++ b/storage/session.go @@ -36,7 +36,6 @@ type Session struct { user *user.User loaded bool - } // Initialize a new Session object diff --git a/storage/session_test.go b/storage/session_test.go index 5101075bffc1bb05100c8683b0f9493ee597a916..a89a934f1439e5edf920c0785e1448fd6ebbb776 100644 --- a/storage/session_test.go +++ b/storage/session_test.go @@ -50,4 +50,4 @@ func TestSession_Smoke(t *testing.T) { if bytes.Compare(o.Data, []byte("test")) != 0 { t.Errorf("Failed to get data") } -} \ No newline at end of file +}