Skip to content
Snippets Groups Projects
Commit 736f5c48 authored by Jonah Husson's avatar Jonah Husson
Browse files

Merge branch 'hotfix/extraChecks' into 'release'

Fix extraChecks

See merge request !80
parents 72f3cfa0 ee08ef51
No related branches found
No related tags found
2 merge requests!117Release,!80Fix extraChecks
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
////////////////////////////////////////////////////////////////////////////////
package interfaces
// DefaultExtraChecks is the default value for ExtraChecks on reception.Identity
const DefaultExtraChecks = 10
...@@ -10,6 +10,7 @@ package ephemeral ...@@ -10,6 +10,7 @@ package ephemeral
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/reception" "gitlab.com/elixxir/client/storage/reception"
...@@ -149,6 +150,7 @@ func generateIdentities(protoIds []ephemeral.ProtoIdentity, ourId *id.ID, ...@@ -149,6 +150,7 @@ func generateIdentities(protoIds []ephemeral.ProtoIdentity, ourId *id.ID,
StartValid: eid.Start.Add(-validityGracePeriod), StartValid: eid.Start.Add(-validityGracePeriod),
EndValid: eid.End.Add(validityGracePeriod), EndValid: eid.End.Add(validityGracePeriod),
Ephemeral: false, Ephemeral: false,
ExtraChecks: interfaces.DefaultExtraChecks,
} }
} }
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/interfaces/utility" "gitlab.com/elixxir/client/interfaces/utility"
"gitlab.com/elixxir/client/storage/reception" "gitlab.com/elixxir/client/storage/reception"
...@@ -92,7 +93,7 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte, ...@@ -92,7 +93,7 @@ func (m *Manager) transmitSingleUse(partner contact2.Contact, payload []byte,
Source: rid, Source: rid,
AddressSize: addressSize, AddressSize: addressSize,
End: timeStart.Add(2 * timeout), End: timeStart.Add(2 * timeout),
ExtraChecks: 10, ExtraChecks: interfaces.DefaultExtraChecks,
StartValid: timeStart.Add(-2 * timeout), StartValid: timeStart.Add(-2 * timeout),
EndValid: timeStart.Add(2 * timeout), EndValid: timeStart.Add(2 * timeout),
Ephemeral: true, Ephemeral: true,
......
...@@ -176,7 +176,7 @@ func (s *Store) AddIdentity(identity Identity) error { ...@@ -176,7 +176,7 @@ func (s *Store) AddIdentity(identity Identity) error {
// Do not make duplicates of IDs // Do not make duplicates of IDs
if _, ok := s.present[idH]; ok { if _, ok := s.present[idH]; ok {
jww.DEBUG.Printf("Ignoring duplicate identity for %d (%s)", jww.DEBUG.Printf("Ignoring duplicate identity for %d (%s)",
identity.EphId, identity.Source) identity.EphId.Int64(), identity.Source)
return nil return nil
} }
...@@ -248,6 +248,7 @@ func (s *Store) SetToExpire(addressSize uint8) { ...@@ -248,6 +248,7 @@ func (s *Store) SetToExpire(addressSize uint8) {
func (s *Store) prune(now time.Time) { func (s *Store) prune(now time.Time) {
lengthBefore := len(s.active) lengthBefore := len(s.active)
var pruned []int64
// Prune the list // Prune the list
for i := 0; i < len(s.active); i++ { for i := 0; i < len(s.active); i++ {
...@@ -257,6 +258,7 @@ func (s *Store) prune(now time.Time) { ...@@ -257,6 +258,7 @@ func (s *Store) prune(now time.Time) {
jww.ERROR.Printf("Failed to delete Identity for %s: %+v", jww.ERROR.Printf("Failed to delete Identity for %s: %+v",
inQuestion, err) inQuestion, err)
} }
pruned = append(pruned, inQuestion.EphId.Int64())
s.active = append(s.active[:i], s.active[i+1:]...) s.active = append(s.active[:i], s.active[i+1:]...)
...@@ -266,7 +268,7 @@ func (s *Store) prune(now time.Time) { ...@@ -266,7 +268,7 @@ func (s *Store) prune(now time.Time) {
// Save the list if it changed // Save the list if it changed
if lengthBefore != len(s.active) { if lengthBefore != len(s.active) {
jww.INFO.Printf("Pruned %d identities", lengthBefore-len(s.active)) jww.INFO.Printf("Pruned %d identities [%+v]", lengthBefore-len(s.active), pruned)
if err := s.save(); err != nil { if err := s.save(); err != nil {
jww.FATAL.Panicf("Failed to store reception storage: %+v", err) jww.FATAL.Panicf("Failed to store reception storage: %+v", err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment