diff --git a/go.mod b/go.mod index 6a4a4e0ec44a388d793f37cf381c88431633a8c7..567d1fd78d9a8d5d4d040b18afcfdad750d1aa54 100644 --- a/go.mod +++ b/go.mod @@ -23,10 +23,10 @@ require ( gitlab.com/elixxir/comms v0.0.4-0.20210121222442-b714136536e9 gitlab.com/elixxir/crypto v0.0.7-0.20210121204803-2caab60ff687 gitlab.com/elixxir/ekv v0.1.4 - gitlab.com/elixxir/primitives v0.0.3-0.20210121204717-e15ada7f0a73 + gitlab.com/elixxir/primitives v0.0.3-0.20210122185056-ad244787d961 gitlab.com/xx_network/comms v0.0.4-0.20210121204701-7a1eb0542424 gitlab.com/xx_network/crypto v0.0.5-0.20210121204626-b251b926e4f7 - gitlab.com/xx_network/primitives v0.0.4-0.20210121203635-8a771fc14f8a + gitlab.com/xx_network/primitives v0.0.4-0.20210201180820-639f0a366d52 golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect golang.org/x/sys v0.0.0-20210105210732-16f7687f5001 // indirect diff --git a/go.sum b/go.sum index f28c68b50b466371024cb14540a1c62b6054c9c8..0c6eefea51c6f1a490a482a0e42de313c7142dbc 100644 --- a/go.sum +++ b/go.sum @@ -322,6 +322,8 @@ gitlab.com/elixxir/primitives v0.0.3-0.20210107183456-9cf6fe2de1e5 h1:50HbCJWirp gitlab.com/elixxir/primitives v0.0.3-0.20210107183456-9cf6fe2de1e5/go.mod h1:Ph6isHUDVjmRUd9DioyKpd8W9J52gKBiDeue4DCygXA= gitlab.com/elixxir/primitives v0.0.3-0.20210121204717-e15ada7f0a73 h1:9h+pCc1ceIWDR1CM5sdoV7KHvNYzKQRJjeIfc26fyDU= gitlab.com/elixxir/primitives v0.0.3-0.20210121204717-e15ada7f0a73/go.mod h1:bGYfAGerVVZhNzh+PxOMZVG7iYAUfInYvtdAkAqgiY8= +gitlab.com/elixxir/primitives v0.0.3-0.20210122185056-ad244787d961 h1:BUN6bUBmTeebwYvTQ5yVi1iJlNAhjR7kEndcsV339dE= +gitlab.com/elixxir/primitives v0.0.3-0.20210122185056-ad244787d961/go.mod h1:bGYfAGerVVZhNzh+PxOMZVG7iYAUfInYvtdAkAqgiY8= gitlab.com/xx_network/comms v0.0.0-20200805174823-841427dd5023/go.mod h1:owEcxTRl7gsoM8c3RQ5KAm5GstxrJp5tn+6JfQ4z5Hw= gitlab.com/xx_network/comms v0.0.4-0.20201130190834-365ddae56e7b/go.mod h1:YViGbRj7FjJYoaO4NpALGEd9dK/l8uUT000FEBbUTL8= gitlab.com/xx_network/comms v0.0.4-0.20201217200138-87075d5b4ffd h1:4LjS3UuBNA/AaglIJ+k1IBoxYgCWt+FM1MPYxjAFfaQ= @@ -369,6 +371,16 @@ gitlab.com/xx_network/primitives v0.0.4-0.20210118193646-93176e2e6925 h1:n40/5N6 gitlab.com/xx_network/primitives v0.0.4-0.20210118193646-93176e2e6925/go.mod h1:cs0QlFpdMDI6lAo61lDRH2JZz+3aVkHy+QogOB6F/qc= gitlab.com/xx_network/primitives v0.0.4-0.20210121203635-8a771fc14f8a h1:ZDv8RHUsl9pjIkgqd8u6y00P+6TXEASwBg9dpvHSsT0= gitlab.com/xx_network/primitives v0.0.4-0.20210121203635-8a771fc14f8a/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= +gitlab.com/xx_network/primitives v0.0.4-0.20210127181825-f9178f9d19b5 h1:dI/3SkJie/Twy4ZZnsNncyiLI6KHJboaRagSU5V96YY= +gitlab.com/xx_network/primitives v0.0.4-0.20210127181825-f9178f9d19b5/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= +gitlab.com/xx_network/primitives v0.0.4-0.20210129181607-5b719add9171 h1:9nvaBYeOH/f8Ev/1b3IhoJdrxXaQZ5Lb/tFe1GzqH00= +gitlab.com/xx_network/primitives v0.0.4-0.20210129181607-5b719add9171/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= +gitlab.com/xx_network/primitives v0.0.4-0.20210201174745-f294e495260d h1:tXEJOJq6rIizJyo/fgs6G17isq9UMahHx6BPtXgheLg= +gitlab.com/xx_network/primitives v0.0.4-0.20210201174745-f294e495260d/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= +gitlab.com/xx_network/primitives v0.0.4-0.20210201180649-48711cee9127 h1:DYYHQeNyh/6Cj3swZYy8bAYFL4yqxedu2dFZMDt8D3M= +gitlab.com/xx_network/primitives v0.0.4-0.20210201180649-48711cee9127/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= +gitlab.com/xx_network/primitives v0.0.4-0.20210201180820-639f0a366d52 h1:gZk8XTQOAFt3IUd2LUsWWYpQQz5ktQF5uD+gV4pu4e8= +gitlab.com/xx_network/primitives v0.0.4-0.20210201180820-639f0a366d52/go.mod h1:9imZHvYwNFobxueSvVtHneZLk9wTK7HQTzxPm+zhFhE= gitlab.com/xx_network/ring v0.0.2 h1:TlPjlbFdhtJrwvRgIg4ScdngMTaynx/ByHBRZiXCoL0= gitlab.com/xx_network/ring v0.0.2/go.mod h1:aLzpP2TiZTQut/PVHR40EJAomzugDdHXetbieRClXIM= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= diff --git a/network/ephemeral/check_test.go b/network/ephemeral/check_test.go new file mode 100644 index 0000000000000000000000000000000000000000..847b63ea2a6d25bc7a1fd04fb7f967044a416617 --- /dev/null +++ b/network/ephemeral/check_test.go @@ -0,0 +1 @@ +package ephemeral diff --git a/network/ephemeral/identity.go b/network/ephemeral/identity.go new file mode 100644 index 0000000000000000000000000000000000000000..847b63ea2a6d25bc7a1fd04fb7f967044a416617 --- /dev/null +++ b/network/ephemeral/identity.go @@ -0,0 +1 @@ +package ephemeral diff --git a/network/manager.go b/network/manager.go index fe1438705500fb699ddea3028f44d5b23a058d51..28d8bea14306f31f3d6cc6c8396a424d3a955e27 100644 --- a/network/manager.go +++ b/network/manager.go @@ -126,7 +126,6 @@ func (m *manager) Follow() (stoppable.Stoppable, error) { // Round processing multi.Add(m.round.StartProcessors()) - m.Session.Ephemeral() // Ephemeral ID tracking multi.Add(ephemeral.Check(m.Session, m.Comms.Id)) diff --git a/storage/ephemeral/store.go b/storage/ephemeral/store.go deleted file mode 100644 index 6dbff903235cc6e342cd7fd88bc9f224b4e207ae..0000000000000000000000000000000000000000 --- a/storage/ephemeral/store.go +++ /dev/null @@ -1,138 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// -package ephemeral - -import ( - "github.com/pkg/errors" - jww "github.com/spf13/jwalterweatherman" - "gitlab.com/elixxir/client/storage/versioned" - "sync" - "time" -) - -const ( - storePrefix = "ephemeralTimestamp" - ephemeralVersion = 0 - timestampKey = "timestampKeyStore" -) - -type Store struct { - kv *versioned.KV - // Timestamp of last check for ephemeral Ids - timestamp time.Time - mux sync.RWMutex -} - -// NewStore creates a new store. -func NewStore(kv *versioned.KV) (*Store, error) { - kv = kv.Prefix(storePrefix) - s := &Store{ - kv: kv, - timestamp: time.Time{}, - } - - return s, s.save() -} - -// loads the ephemeral storage object -func LoadStore(kv *versioned.KV) (*Store, error) { - kv = kv.Prefix(storePrefix) - s := &Store{ - timestamp: time.Time{}, - kv: kv, - } - - obj, err := kv.Get(timestampKey) - if err != nil { - return nil, err - } - - if err = s.unmarshal(obj.Data); err != nil { - return nil, err - } - - return s, nil -} - -// Returns the stored timestamp. If a timestamp is empty, we check disk. -// If the disk's timestamp is empty. we return an error. -// Otherwise, we return the valid timestamp found -func (s *Store) GetTimestamp() (time.Time, error) { - s.mux.RLock() - defer s.mux.RUnlock() - - ts := s.timestamp - - // Check that t - if ts.Equal(time.Time{}) { - obj, err := s.kv.Get(timestampKey) - if err != nil { - return time.Time{}, err - } - - ts = time.Time{} - if err := ts.UnmarshalBinary(obj.Data); err != nil { - return time.Time{}, err - } - - // If still an empty time object, then no timestamp exists - if ts.Equal(time.Time{}) { - return time.Time{}, errors.Errorf("No timestamp has been found") - } - } - - return ts, nil -} - -// Updates the stored time stamp with the time passed in -func (s *Store) UpdateTimestamp(ts time.Time) error { - s.mux.Lock() - defer s.mux.Unlock() - - - s.timestamp = ts - - if err := s.save(); err != nil { - jww.FATAL.Panicf("Failed to update timestamp of last check for ephemeral IDs") - } - - return nil -} - -// stores the ephemeral store -func (s *Store) save() error { - - data, err := s.marshal() - if err != nil { - return err - } - - obj := versioned.Object{ - Version: ephemeralVersion, - Timestamp: time.Now(), - Data: data, - } - - return s.kv.Set(timestampKey, &obj) -} - -// builds a byte representation of the store -func (s *Store) marshal() ([]byte, error) { - return s.timestamp.MarshalBinary() -} - -// restores the data for a store from the byte representation of the store -func (s *Store) unmarshal(b []byte) error { - ts := time.Time{} - if err := ts.UnmarshalBinary(b); err != nil { - return err - } - - s.timestamp = ts - - return nil -} diff --git a/storage/ephemeral/store_test.go b/storage/ephemeral/store_test.go deleted file mode 100644 index bd94ae90d7d39564c195788ccb042a8e313069d8..0000000000000000000000000000000000000000 --- a/storage/ephemeral/store_test.go +++ /dev/null @@ -1,9 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright © 2020 xx network SEZC // -// // -// Use of this source code is governed by a license that can be found in the // -// LICENSE file // -/////////////////////////////////////////////////////////////////////////////// -package ephemeral - - diff --git a/storage/session.go b/storage/session.go index 0773cccf3d952c9f07f02e1336caf639efed1e58..db4e21e1cb9d6d2277cd9f5e34e79f1cb000cb51 100644 --- a/storage/session.go +++ b/storage/session.go @@ -17,7 +17,6 @@ import ( "gitlab.com/elixxir/client/storage/cmix" "gitlab.com/elixxir/client/storage/conversation" "gitlab.com/elixxir/client/storage/e2e" - "gitlab.com/elixxir/client/storage/ephemeral" "gitlab.com/elixxir/client/storage/partition" "gitlab.com/elixxir/client/storage/reception" "gitlab.com/elixxir/client/storage/user" @@ -58,7 +57,6 @@ type Session struct { criticalRawMessages *utility.CmixMessageBuffer garbledMessages *utility.MeteredCmixMessageBuffer checkedRounds *utility.KnownRounds - ephemeral *ephemeral.Store reception *reception.Store } @@ -277,12 +275,6 @@ func (s *Session) Partition() *partition.Store { return s.partition } -func (s *Session) Ephemeral() *ephemeral.Store { - s.mux.RLock() - defer s.mux.RUnlock() - return s.ephemeral -} - func (s *Session) Reception() *reception.Store { s.mux.RLock() defer s.mux.RUnlock()