diff --git a/bindings/callback.go b/bindings/callback.go index 34d26ecccaf4b4f105a2ab2e7b29d82fb1fe3728..d0fe898c204188646c74c647f41759b5988cbf69 100644 --- a/bindings/callback.go +++ b/bindings/callback.go @@ -97,16 +97,15 @@ type ClientError interface { Report(source, message, trace string) } - -type LogWriter interface{ +type LogWriter interface { Log(string) } -type writerAdapter struct{ +type writerAdapter struct { lw LogWriter } -func (wa *writerAdapter)Write(p []byte) (n int, err error){ +func (wa *writerAdapter) Write(p []byte) (n int, err error) { wa.lw.Log(string(p)) return len(p), nil } diff --git a/interfaces/params/network.go b/interfaces/params/network.go index b84c38a09310f13d13a5cd74d4ddfb83c62fc717..24af3d540f2e7824328641c07ddf325c37e86dfc 100644 --- a/interfaces/params/network.go +++ b/interfaces/params/network.go @@ -35,13 +35,13 @@ type Network struct { func GetDefaultNetwork() Network { n := Network{ - TrackNetworkPeriod: 100 * time.Millisecond, - MaxCheckedRounds: 500, - RegNodesBufferLen: 500, - NetworkHealthTimeout: 30 * time.Second, - E2EParams: GetDefaultE2ESessionParams(), + TrackNetworkPeriod: 100 * time.Millisecond, + MaxCheckedRounds: 500, + RegNodesBufferLen: 500, + NetworkHealthTimeout: 30 * time.Second, + E2EParams: GetDefaultE2ESessionParams(), ParallelNodeRegistrations: 8, - KnownRoundsThreshold: 1500, //5 rounds/sec * 60 sec/min * 5 min + KnownRoundsThreshold: 1500, //5 rounds/sec * 60 sec/min * 5 min } n.Rounds = GetDefaultRounds() n.Messages = GetDefaultMessage() diff --git a/interfaces/params/rounds.go b/interfaces/params/rounds.go index 87fa53fc04517b8262ffbc8be624b3989dddeb91..07c4c3c25d83f3c115263bef0269ab1c9226c7ee 100644 --- a/interfaces/params/rounds.go +++ b/interfaces/params/rounds.go @@ -39,9 +39,9 @@ func GetDefaultRounds() Rounds { HistoricalRoundsPeriod: 100 * time.Millisecond, NumMessageRetrievalWorkers: 8, - HistoricalRoundsBufferLen: 1000, - LookupRoundsBufferLen: 2000, - ForceHistoricalRounds: false, + HistoricalRoundsBufferLen: 1000, + LookupRoundsBufferLen: 2000, + ForceHistoricalRounds: false, MaxHistoricalRoundsRetries: 3, } } diff --git a/keyExchange/exchange.go b/keyExchange/exchange.go index d94e8800f60d440c3c0c8b41564c04f4ada32ba7..42b7a177e10595bf45dd1b11fe7715e3a0b0c4f2 100644 --- a/keyExchange/exchange.go +++ b/keyExchange/exchange.go @@ -32,7 +32,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte // create the trigger stoppable triggerStop := stoppable.NewSingle(keyExchangeTriggerName) - cleanupTrigger := func(){ + cleanupTrigger := func() { switchboard.Unregister(triggerID) } @@ -46,7 +46,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte // register the confirm stoppable confirmStop := stoppable.NewSingle(keyExchangeConfirmName) - cleanupConfirm := func(){ + cleanupConfirm := func() { switchboard.Unregister(confirmID) } diff --git a/network/checkedRounds.go b/network/checkedRounds.go index 8ffa9ba39804fd70017123859cf60137f12f8e78..d104ac9589bfb9d7b7bce41d967b7013fdfb9141 100644 --- a/network/checkedRounds.go +++ b/network/checkedRounds.go @@ -7,36 +7,35 @@ import ( "gitlab.com/xx_network/primitives/id" ) - type idFingerprint [16]byte -type checkedRounds struct{ +type checkedRounds struct { lookup map[idFingerprint]*checklist } -type checklist struct{ +type checklist struct { m map[id.Round]interface{} l *list.List } -func newCheckedRounds()*checkedRounds{ +func newCheckedRounds() *checkedRounds { return &checkedRounds{ lookup: make(map[idFingerprint]*checklist), } } -func (cr *checkedRounds)Check(identity reception.IdentityUse, rid id.Round)bool{ +func (cr *checkedRounds) Check(identity reception.IdentityUse, rid id.Round) bool { idFp := getIdFingerprint(identity) cl, exists := cr.lookup[idFp] - if !exists{ + if !exists { cl = &checklist{ m: make(map[id.Round]interface{}), l: list.New().Init(), } - cr.lookup[idFp]=cl + cr.lookup[idFp] = cl } - if _, exists := cl.m[rid]; !exists{ + if _, exists := cl.m[rid]; !exists { cl.m[rid] = nil cl.l.PushBack(rid) return true @@ -44,7 +43,7 @@ func (cr *checkedRounds)Check(identity reception.IdentityUse, rid id.Round)bool{ return false } -func (cr *checkedRounds)Prune(identity reception.IdentityUse, earliestAllowed id.Round){ +func (cr *checkedRounds) Prune(identity reception.IdentityUse, earliestAllowed id.Round) { idFp := getIdFingerprint(identity) cl, exists := cr.lookup[idFp] if !exists { @@ -52,19 +51,19 @@ func (cr *checkedRounds)Prune(identity reception.IdentityUse, earliestAllowed id } e := cl.l.Front() - for e!=nil { - if e.Value.(id.Round)<earliestAllowed{ - delete(cl.m,e.Value.(id.Round)) + for e != nil { + if e.Value.(id.Round) < earliestAllowed { + delete(cl.m, e.Value.(id.Round)) lastE := e e = e.Next() cl.l.Remove(lastE) - }else{ + } else { break } } } -func getIdFingerprint(identity reception.IdentityUse)idFingerprint{ +func getIdFingerprint(identity reception.IdentityUse) idFingerprint { h := md5.New() h.Write(identity.EphId[:]) h.Write(identity.Source[:]) @@ -72,4 +71,4 @@ func getIdFingerprint(identity reception.IdentityUse)idFingerprint{ fp := idFingerprint{} copy(fp[:], h.Sum(nil)) return fp -} \ No newline at end of file +} diff --git a/network/rounds/check.go b/network/rounds/check.go index 9deb3ec6c16fb227a6406c9fd6181ffcf6e4d8b1..a22bafd8e7931ecbbe673b2df1c071bad4fb329c 100644 --- a/network/rounds/check.go +++ b/network/rounds/check.go @@ -47,9 +47,9 @@ func serializeRound(roundId id.Round) []byte { return b } -func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.IdentityUse){ +func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.IdentityUse) { ri, err := m.Instance.GetRound(roundID) - if err !=nil || m.params.ForceHistoricalRounds { + if err != nil || m.params.ForceHistoricalRounds { if m.params.ForceHistoricalRounds { jww.WARN.Printf("Forcing use of historical rounds for round ID %d.", roundID) @@ -59,8 +59,8 @@ func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.Iden identity.Source) // If we didn't find it, send to Historical Rounds Retrieval m.historicalRounds <- historicalRoundRequest{ - rid: roundID, - identity: identity, + rid: roundID, + identity: identity, numAttempts: 0, } } else { @@ -74,4 +74,4 @@ func (m *Manager) GetMessagesFromRound(roundID id.Round, identity reception.Iden } } -} \ No newline at end of file +} diff --git a/network/rounds/manager.go b/network/rounds/manager.go index cdc87ea2ca46ccd5ff0b68a437e50ef7aa2ccdd7..942e86319efe8ab05711b901360edbcd37865978 100644 --- a/network/rounds/manager.go +++ b/network/rounds/manager.go @@ -58,4 +58,4 @@ func (m *Manager) StartProcessors() stoppable.Stoppable { multi.Add(stopper) } return multi -} \ No newline at end of file +} diff --git a/stoppable/cleanup.go b/stoppable/cleanup.go index 8111abe206492d4e22cfaffe31195acab58b77c5..b1e2c4561dc87c2af1ec654d48b787d47ca8182e 100644 --- a/stoppable/cleanup.go +++ b/stoppable/cleanup.go @@ -87,7 +87,7 @@ func (c *Cleanup) Close(timeout time.Duration) error { } }) - if err!=nil{ + if err != nil { jww.ERROR.Printf(err.Error()) } diff --git a/storage/cmix/store_test.go b/storage/cmix/store_test.go index f4dfc3a7af59ee29511a2172779c6b919ef6ec6b..63329b769b1706dc4a341988a03e28fe84a37642 100644 --- a/storage/cmix/store_test.go +++ b/storage/cmix/store_test.go @@ -70,7 +70,6 @@ func TestStore_AddRemove(t *testing.T) { } } - // Happy path Add/Has test func TestStore_AddHas(t *testing.T) { // Uncomment to print keys that Set and Get are called on diff --git a/storage/e2e/relationship.go b/storage/e2e/relationship.go index 6efd7081b133fae3845c83e1fbc5ecf3997da1ae..a492a72ed51d0f48f08657d786bc8dc6a3c861ed 100644 --- a/storage/e2e/relationship.go +++ b/storage/e2e/relationship.go @@ -303,9 +303,9 @@ func (r *relationship) getNewestRekeyableSession() *Session { // always valid. It isn't clear it can fail though because we are // accessing the data in the same order it would be written (i think) if s.Status() != RekeyEmpty { - if s.IsConfirmed(){ + if s.IsConfirmed() { return s - }else if unconfirmed == nil{ + } else if unconfirmed == nil { unconfirmed = s } } diff --git a/storage/e2e/relationship_test.go b/storage/e2e/relationship_test.go index 49fa51de4abe7df24421ae8c91b24c09f8c10b45..457e4f6dcd508abd2014248db7738f46badf947a 100644 --- a/storage/e2e/relationship_test.go +++ b/storage/e2e/relationship_test.go @@ -571,4 +571,4 @@ func Test_relationship_getNewestRekeyableSession(t *testing.T) { } }) } -} \ No newline at end of file +} diff --git a/storage/e2e/session.go b/storage/e2e/session.go index 5f0344378ae7f106edd4c447904dd89cb2b6ca94..ad684725a04918389f706566e44642c6c1fbaf16 100644 --- a/storage/e2e/session.go +++ b/storage/e2e/session.go @@ -119,7 +119,7 @@ func newSession(ship *relationship, t RelationshipType, myPrivKey, partnerPubKey relationshipFingerprint: relationshipFingerprint, negotiationStatus: negotiationStatus, partnerSource: trigger, - partner: ship.manager.partner.DeepCopy(), + partner: ship.manager.partner.DeepCopy(), } session.kv = session.generate(ship.kv) @@ -173,8 +173,8 @@ func loadSession(ship *relationship, kv *versioned.KV, } session.relationshipFingerprint = relationshipFingerprint - if !session.partner.Cmp(ship.manager.partner){ - return nil, errors.Errorf("Stored partner (%s) did not match " + + if !session.partner.Cmp(ship.manager.partner) { + return nil, errors.Errorf("Stored partner (%s) did not match "+ "relationship partner (%s)", session.partner, ship.manager.partner) } diff --git a/storage/e2e/session_test.go b/storage/e2e/session_test.go index 800cac5410e8b5236d9c89aa5ed90c36a49bc654..258cea9edab79a1e0fe6f214b4b6a78e4814e9d3 100644 --- a/storage/e2e/session_test.go +++ b/storage/e2e/session_test.go @@ -628,8 +628,8 @@ func makeTestSession() (*Session, *context) { e2eParams: params.GetDefaultE2ESessionParams(), relationship: &relationship{ manager: &Manager{ - ctx: ctx, - kv: kv, + ctx: ctx, + kv: kv, partner: &id.ID{}, }, kv: kv, @@ -638,7 +638,7 @@ func makeTestSession() (*Session, *context) { t: Receive, negotiationStatus: Confirmed, rekeyThreshold: 5, - partner: &id.ID{}, + partner: &id.ID{}, } var err error s.keyState, err = newStateVector(s.kv, diff --git a/storage/e2e/store.go b/storage/e2e/store.go index a0a427e0abbff557514b6d4197335cc75c427a69..e647cacab042388b667d383f670c8082c450b591 100644 --- a/storage/e2e/store.go +++ b/storage/e2e/store.go @@ -260,8 +260,8 @@ func (s *Store) unmarshal(b []byte) error { partnerID, err.Error()) } - if !manager.GetPartnerID().Cmp(partnerID){ - jww.FATAL.Panicf("Loaded a manager with the wrong partner " + + if !manager.GetPartnerID().Cmp(partnerID) { + jww.FATAL.Panicf("Loaded a manager with the wrong partner "+ "ID: \n\t loaded: %s \n\t present: %s", partnerID, manager.GetPartnerID()) } diff --git a/storage/rounds/unknownRounds_test.go b/storage/rounds/unknownRounds_test.go index ffc9bdd46a74060948a7a06d724cf2590d203da4..f437e0839f7d37208f2d7b5c826e6a6cfeb7d5b2 100644 --- a/storage/rounds/unknownRounds_test.go +++ b/storage/rounds/unknownRounds_test.go @@ -27,7 +27,7 @@ func TestNewUnknownRoundsStore(t *testing.T) { params: DefaultUnknownRoundsParams(), } - store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) + store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) // Compare manually created object with NewUnknownRoundsStore if !reflect.DeepEqual(expectedStore, store) { @@ -60,7 +60,7 @@ func TestNewUnknownRoundsStore(t *testing.T) { // Full test func TestUnknownRoundsStore_Iterate(t *testing.T) { kv := versioned.NewKV(make(ekv.Memstore)) - store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) + store := NewUnknownRounds(kv, DefaultUnknownRoundsParams()) // Return true only for rounds that are even mockChecker := func(rid id.Round) bool { @@ -116,7 +116,7 @@ func TestUnknownRoundsStore_Iterate(t *testing.T) { // Iterate over map until all rounds have checks incremented over // maxCheck for i := 0; i < defaultMaxCheck+1; i++ { - _ = store.Iterate(mockChecker,[]id.Round{}) + _ = store.Iterate(mockChecker, []id.Round{}) }