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

Merge branch 'release' into XX-3134/GwHostPool

# Conflicts:
#	api/version_vars.go
#	go.mod
#	go.sum
parents 626b1d67 9d290b7b
No related branches found
No related tags found
No related merge requests found
Showing
with 377 additions and 198 deletions
...@@ -429,7 +429,6 @@ func (c *Client) StopNetworkFollower(timeout time.Duration) error { ...@@ -429,7 +429,6 @@ func (c *Client) StopNetworkFollower(timeout time.Duration) error {
if err != nil { if err != nil {
return errors.WithMessage(err, "Failed to Stop the Network Follower") return errors.WithMessage(err, "Failed to Stop the Network Follower")
} }
close(c.clientErrorChannel)
err = c.runner.Close(timeout) err = c.runner.Close(timeout)
if err != nil { if err != nil {
return errors.WithMessage(err, "Failed to Stop the Network Follower") return errors.WithMessage(err, "Failed to Stop the Network Follower")
......
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at // This file was generated by robots at
// 2021-03-23 15:42:17.414835 -0500 CDT m=+0.023247933 // 2021-04-02 08:56:27.8657223 -0700 PDT m=+0.054483401
package api package api
const GITVERSION = `0e4fae51 Merge branch 'betterNumRegistered' into 'release'` const GITVERSION = `6020ab79 removed an extranious print`
const SEMVER = "2.2.1" const SEMVER = "2.3.0"
const DEPENDENCIES = `module gitlab.com/elixxir/client const DEPENDENCIES = `module gitlab.com/elixxir/client
go 1.13 go 1.13
...@@ -13,10 +13,12 @@ require ( ...@@ -13,10 +13,12 @@ require (
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.4.3 github.com/golang/protobuf v1.4.3
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/liyue201/goqr v0.0.0-20200803022322-df443203d4ea
github.com/magiconair/properties v1.8.4 // indirect github.com/magiconair/properties v1.8.4 // indirect
github.com/mitchellh/mapstructure v1.4.0 // indirect github.com/mitchellh/mapstructure v1.4.0 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect github.com/pelletier/go-toml v1.8.1 // indirect
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/smartystreets/assertions v1.0.1 // indirect github.com/smartystreets/assertions v1.0.1 // indirect
github.com/spf13/afero v1.5.1 // indirect github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cast v1.3.1 // indirect
...@@ -24,18 +26,18 @@ require ( ...@@ -24,18 +26,18 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
github.com/spf13/viper v1.7.1 github.com/spf13/viper v1.7.1
gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228
gitlab.com/elixxir/comms v0.0.4-0.20210323165848-495b7efbf1af gitlab.com/elixxir/comms v0.0.4-0.20210401210158-6053ad2e224c
gitlab.com/elixxir/crypto v0.0.7-0.20210319231554-b73b6e62ddbc gitlab.com/elixxir/crypto v0.0.7-0.20210401210040-b7f1da24ef13
gitlab.com/elixxir/ekv v0.1.4 gitlab.com/elixxir/ekv v0.1.4
gitlab.com/elixxir/primitives v0.0.3-0.20210309193003-ef42ebb4800b gitlab.com/elixxir/primitives v0.0.3-0.20210401175645-9b7b92f74ec4
gitlab.com/xx_network/comms v0.0.4-0.20210323140408-2b2613abb5a3 gitlab.com/xx_network/comms v0.0.4-0.20210401160731-7b8890cdd8ad
gitlab.com/xx_network/crypto v0.0.5-0.20210319231335-249c6b1aa323 gitlab.com/xx_network/crypto v0.0.5-0.20210401160648-4f06cace9123
gitlab.com/xx_network/primitives v0.0.4-0.20210309173740-eb8cd411334a gitlab.com/xx_network/primitives v0.0.4-0.20210331161816-ed23858bdb93
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect google.golang.org/genproto v0.0.0-20210105202744-fe13368bc0e1 // indirect
google.golang.org/grpc v1.34.0 // indirect google.golang.org/grpc v1.34.0 // indirect
google.golang.org/protobuf v1.25.0 google.golang.org/protobuf v1.26.0-rc.1
gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect
) )
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/contact" "gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
"gitlab.com/elixxir/client/storage/auth" "gitlab.com/elixxir/client/storage/auth"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
...@@ -25,47 +26,54 @@ import ( ...@@ -25,47 +26,54 @@ import (
func (m *Manager) StartProcessies() stoppable.Stoppable { func (m *Manager) StartProcessies() stoppable.Stoppable {
stop := stoppable.NewSingle("Auth") stop := stoppable.NewSingle("Auth")
authStore := m.storage.Auth()
grp := m.storage.E2e().GetGroup()
go func() { go func() {
for {
select { select {
case <-stop.Quit(): case <-stop.Quit():
return return
case msg := <-m.rawMessages: case msg := <-m.rawMessages:
m.processAuthMessage(msg)
}
}
}()
return stop
}
func (m *Manager) processAuthMessage(msg message.Receive) {
authStore := m.storage.Auth()
//lookup the message, check if it is an auth request //lookup the message, check if it is an auth request
cmixMsg := format.Unmarshal(msg.Payload) cmixMsg := format.Unmarshal(msg.Payload)
fp := cmixMsg.GetKeyFP() fp := cmixMsg.GetKeyFP()
jww.INFO.Printf("RAW AUTH FP: %v", fp) jww.INFO.Printf("RAW AUTH FP: %v", fp)
// this takes the request lock if it is a specific fp, // this takes the request lock if it is a specific fp, all
// all exits after this need to call fail or delete if it is // exits after this need to call fail or delete if it is
// specific // specific
fpType, sr, myHistoricalPrivKey, err := authStore.GetFingerprint(fp) fpType, sr, myHistoricalPrivKey, err := authStore.GetFingerprint(fp)
if err != nil { if err != nil {
jww.TRACE.Printf("FINGERPRINT FAILURE: %s", err.Error()) jww.TRACE.Printf("FINGERPRINT FAILURE: %s", err.Error())
// if the lookup fails, ignore the message. It is likely // if the lookup fails, ignore the message. It is
// garbled or for a different protocol // likely garbled or for a different protocol
break return
} }
//denote that the message is not garbled //denote that the message is not garbled
m.storage.GetGarbledMessages().Remove(cmixMsg) m.storage.GetGarbledMessages().Remove(cmixMsg)
grp := m.storage.E2e().GetGroup()
switch fpType { switch fpType {
// if it is general, that means a new request has been received
case auth.General: case auth.General:
// if it is general, that means a new request has
// been received
m.handleRequest(cmixMsg, myHistoricalPrivKey, grp) m.handleRequest(cmixMsg, myHistoricalPrivKey, grp)
case auth.Specific:
// if it is specific, that means the original request was sent // if it is specific, that means the original request was sent
// by this users and a confirmation has been received // by this users and a confirmation has been received
case auth.Specific: jww.INFO.Printf("Received AutConfirm from %s, msgDigest: %s",
jww.INFO.Printf("Received AutConfirm from %s,"+ sr.GetPartner(), cmixMsg.Digest())
" msgDigest: %s", sr.GetPartner(), cmixMsg.Digest())
m.handleConfirm(cmixMsg, sr, grp) m.handleConfirm(cmixMsg, sr, grp)
} }
} }
}()
return stop
}
func (m *Manager) handleRequest(cmixMsg format.Message, func (m *Manager) handleRequest(cmixMsg format.Message,
myHistoricalPrivKey *cyclic.Int, grp *cyclic.Group) { myHistoricalPrivKey *cyclic.Int, grp *cyclic.Group) {
...@@ -152,8 +160,8 @@ func (m *Manager) handleRequest(cmixMsg format.Message, ...@@ -152,8 +160,8 @@ func (m *Manager) handleRequest(cmixMsg format.Message,
" msgDigest: %s which has been requested, auto-confirming", " msgDigest: %s which has been requested, auto-confirming",
partnerID, cmixMsg.Digest()) partnerID, cmixMsg.Digest())
// do the confirmation // do the confirmation
if err := m.doConfirm(sr2, grp, partnerPubKey, myPubKey, if err := m.doConfirm(sr2, grp, partnerPubKey, m.storage.E2e().GetDHPrivateKey(),
ecrFmt.GetOwnership()); err != nil { sr2.GetPartnerHistoricalPubKey(), ecrFmt.GetOwnership()); err != nil {
jww.WARN.Printf("Auto Confirmation with %s failed: %s", jww.WARN.Printf("Auto Confirmation with %s failed: %s",
partnerID, err) partnerID, err)
} }
...@@ -241,8 +249,8 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest, ...@@ -241,8 +249,8 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
} }
// finalize the confirmation // finalize the confirmation
if err := m.doConfirm(sr, grp, partnerPubKey, sr.GetPartnerHistoricalPubKey(), if err := m.doConfirm(sr, grp, partnerPubKey, sr.GetMyPrivKey(),
ecrFmt.GetOwnership()); err != nil { sr.GetPartnerHistoricalPubKey(), ecrFmt.GetOwnership()); err != nil {
jww.WARN.Printf("Confirmation failed: %s", err) jww.WARN.Printf("Confirmation failed: %s", err)
m.storage.Auth().Fail(sr.GetPartner()) m.storage.Auth().Fail(sr.GetPartner())
return return
...@@ -250,10 +258,10 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest, ...@@ -250,10 +258,10 @@ func (m *Manager) handleConfirm(cmixMsg format.Message, sr *auth.SentRequest,
} }
func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group, func (m *Manager) doConfirm(sr *auth.SentRequest, grp *cyclic.Group,
partnerPubKey, myPubKeyOwnershipProof *cyclic.Int, ownershipProof []byte) error { partnerPubKey, myPrivateKeyOwnershipProof, partnerPubKeyOwnershipProof *cyclic.Int, ownershipProof []byte) error {
// verify the message came from the intended recipient // verify the message came from the intended recipient
if !cAuth.VerifyOwnershipProof(sr.GetMyPrivKey(), if !cAuth.VerifyOwnershipProof(myPrivateKeyOwnershipProof,
myPubKeyOwnershipProof, grp, ownershipProof) { partnerPubKeyOwnershipProof, grp, ownershipProof) {
return errors.Errorf("Failed authenticate identity for auth "+ return errors.Errorf("Failed authenticate identity for auth "+
"confirmation of %s", sr.GetPartner()) "confirmation of %s", sr.GetPartner())
} }
......
...@@ -33,12 +33,6 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader, ...@@ -33,12 +33,6 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
storage *storage.Session, net interfaces.NetworkManager) error { storage *storage.Session, net interfaces.NetworkManager) error {
/*edge checks generation*/ /*edge checks generation*/
// check that messages can be sent over the network
if !net.GetHealthTracker().IsHealthy() {
return errors.New("Cannot create authenticated message " +
"when the network is not healthy")
}
// check that an authenticated channel does not already exists // check that an authenticated channel does not already exists
if _, err := storage.E2e().GetPartner(partner.ID); err == nil || if _, err := storage.E2e().GetPartner(partner.ID); err == nil ||
!strings.Contains(err.Error(), e2e.NoPartnerErrorStr) { !strings.Contains(err.Error(), e2e.NoPartnerErrorStr) {
...@@ -145,22 +139,25 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader, ...@@ -145,22 +139,25 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
//store the message as a critical message so it will always be sent //store the message as a critical message so it will always be sent
storage.GetCriticalRawMessages().AddProcessing(cmixMsg, partner.ID) storage.GetCriticalRawMessages().AddProcessing(cmixMsg, partner.ID)
go func() {
jww.INFO.Printf("Requesting Auth with %s, msgDigest: %s", jww.INFO.Printf("Requesting Auth with %s, msgDigest: %s",
partner.ID, cmixMsg.Digest()) partner.ID, cmixMsg.Digest())
/*send message*/ /*send message*/
round, _, err := net.SendCMIX(cmixMsg, partner.ID, params.GetDefaultCMIX()) round, _, err := net.SendCMIX(cmixMsg, partner.ID,
params.GetDefaultCMIX())
if err != nil { if err != nil {
// if the send fails just set it to failed, it will but automatically // if the send fails just set it to failed, it will
// retried // but automatically retried
jww.INFO.Printf("Auth Request with %s (msgDigest: %s) failed "+ jww.WARN.Printf("Auth Request with %s (msgDigest: %s)"+
"to transmit: %+v", partner.ID, cmixMsg.Digest(), err) " failed to transmit: %+v", partner.ID,
storage.GetCriticalRawMessages().Failed(cmixMsg, partner.ID) cmixMsg.Digest(), err)
return errors.WithMessage(err, "Auth Request Failed to transmit") storage.GetCriticalRawMessages().Failed(cmixMsg,
partner.ID)
} }
jww.INFO.Printf("Auth Request with %s (msgDigest: %s) sent on round %d", jww.INFO.Printf("Auth Request with %s (msgDigest: %s) sent"+
partner.ID, cmixMsg.Digest(), round) " on round %d", partner.ID, cmixMsg.Digest(), round)
/*check message delivery*/ /*check message delivery*/
sendResults := make(chan ds.EventReturn, 1) sendResults := make(chan ds.EventReturn, 1)
...@@ -172,20 +169,28 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader, ...@@ -172,20 +169,28 @@ func RequestAuth(partner, me contact.Contact, message string, rng io.Reader,
success, numFailed, _ := utility.TrackResults(sendResults, 1) success, numFailed, _ := utility.TrackResults(sendResults, 1)
if !success { if !success {
if numFailed > 0 { if numFailed > 0 {
jww.INFO.Printf("Auth Request with %s (msgDigest: %s) failed "+ jww.WARN.Printf("Auth Request with %s "+
"delivery due to round failure, will retry on reconnect", "(msgDigest: %s) failed "+
"delivery due to round failure, "+
"will retry on reconnect",
partner.ID, cmixMsg.Digest()) partner.ID, cmixMsg.Digest())
} else { } else {
jww.INFO.Printf("Auth Request with %s (msgDigest: %s) failed "+ jww.WARN.Printf("Auth Request with %s "+
"delivery due to timeout, will retry on reconnect", "(msgDigest: %s) failed "+
"delivery due to timeout, "+
"will retry on reconnect",
partner.ID, cmixMsg.Digest()) partner.ID, cmixMsg.Digest())
} }
storage.GetCriticalRawMessages().Failed(cmixMsg, partner.ID) storage.GetCriticalRawMessages().Failed(cmixMsg,
partner.ID)
} else { } else {
jww.INFO.Printf("Auth Request with %s (msgDigest: %s) delivered "+ jww.INFO.Printf("Auth Request with %s (msgDigest: %s) "+
"sucesfully", partner.ID, cmixMsg.Digest()) "delivered sucessfully", partner.ID,
storage.GetCriticalRawMessages().Succeeded(cmixMsg, partner.ID) cmixMsg.Digest())
storage.GetCriticalRawMessages().Succeeded(cmixMsg,
partner.ID)
} }
}()
return nil return nil
} }
///////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
///////////////////////////////////////////////////////////////////////////////
package bindings
import (
"gitlab.com/xx_network/primitives/netTime"
"time"
)
type TimeSource interface {
NowMs() int
}
// SetTimeSource sets the network time to a custom source.
func SetTimeSource(timeNow TimeSource) {
netTime.Now = func() time.Time {
return time.Unix(0, int64(timeNow.NowMs()*int(time.Millisecond)))
}
}
...@@ -52,6 +52,24 @@ var rootCmd = &cobra.Command{ ...@@ -52,6 +52,24 @@ var rootCmd = &cobra.Command{
jww.INFO.Printf("User: %s", user.ReceptionID) jww.INFO.Printf("User: %s", user.ReceptionID)
writeContact(user.GetContact()) writeContact(user.GetContact())
// Get Recipient and/or set it to myself
isPrecanPartner := false
recipientContact := readContact()
recipientID := recipientContact.ID
// Try to get recipientID from destid
if recipientID == nil {
recipientID, isPrecanPartner = parseRecipient(
viper.GetString("destid"))
}
// Set it to myself
if recipientID == nil {
jww.INFO.Printf("sending message to self")
recipientID = user.ReceptionID
recipientContact = user.GetContact()
}
// Set up reception handler // Set up reception handler
swboard := client.GetSwitchboard() swboard := client.GetSwitchboard()
recvCh := make(chan message.Receive, 10000) recvCh := make(chan message.Receive, 10000)
...@@ -65,12 +83,12 @@ var rootCmd = &cobra.Command{ ...@@ -65,12 +83,12 @@ var rootCmd = &cobra.Command{
authMgr.AddGeneralRequestCallback(printChanRequest) authMgr.AddGeneralRequestCallback(printChanRequest)
// If unsafe channels, add auto-acceptor // If unsafe channels, add auto-acceptor
num_channels_confirmed := 0 authConfirmed := false
authMgr.AddGeneralConfirmCallback(func( authMgr.AddGeneralConfirmCallback(func(
partner contact.Contact) { partner contact.Contact) {
jww.INFO.Printf("Channel Confirmed: %s", jww.INFO.Printf("Channel Confirmed: %s",
partner.ID) partner.ID)
num_channels_confirmed++ authConfirmed = recipientID.Cmp(partner.ID)
}) })
if viper.GetBool("unsafe-channel-creation") { if viper.GetBool("unsafe-channel-creation") {
authMgr.AddGeneralRequestCallback(func( authMgr.AddGeneralRequestCallback(func(
...@@ -82,7 +100,8 @@ var rootCmd = &cobra.Command{ ...@@ -82,7 +100,8 @@ var rootCmd = &cobra.Command{
if err != nil { if err != nil {
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
num_channels_confirmed++ authConfirmed = recipientID.Cmp(
requestor.ID)
}) })
} }
...@@ -113,39 +132,53 @@ var rootCmd = &cobra.Command{ ...@@ -113,39 +132,53 @@ var rootCmd = &cobra.Command{
// Send Messages // Send Messages
msgBody := viper.GetString("message") msgBody := viper.GetString("message")
isPrecanPartner := false
recipientContact := readContact()
recipientID := recipientContact.ID
// Try to get recipientID from destid
if recipientID == nil {
recipientID, isPrecanPartner = parseRecipient(
viper.GetString("destid"))
}
// Set it to myself
if recipientID == nil {
jww.INFO.Printf("sending message to self")
recipientID = user.ReceptionID
recipientContact = user.GetContact()
}
time.Sleep(10 * time.Second) time.Sleep(10 * time.Second)
// Accept auth request for this recipient // Accept auth request for this recipient
if viper.GetBool("accept-channel") { if viper.GetBool("accept-channel") {
acceptChannel(client, recipientID) acceptChannel(client, recipientID)
// Do not wait for channel confirmations if we
// accepted one
authConfirmed = true
}
if client.HasAuthenticatedChannel(recipientID) {
jww.INFO.Printf("Authenticated channel already in "+
"place for %s", recipientID)
authConfirmed = true
} }
// Send unsafe messages or not? // Send unsafe messages or not?
unsafe := viper.GetBool("unsafe") unsafe := viper.GetBool("unsafe")
assumeAuth := viper.GetBool("assume-auth-channel")
if !unsafe && !assumeAuth { sendAuthReq := viper.GetBool("send-auth-request")
if !unsafe && !authConfirmed && !isPrecanPartner &&
sendAuthReq {
addAuthenticatedChannel(client, recipientID, addAuthenticatedChannel(client, recipientID,
recipientContact, isPrecanPartner) recipientContact)
// Do not wait for channel confirmations if we } else if !unsafe && !authConfirmed && isPrecanPartner {
// tried to add a channel addPrecanAuthenticatedChannel(client,
num_channels_confirmed++ recipientID, recipientContact)
authConfirmed = true
}
if !unsafe && !authConfirmed {
jww.INFO.Printf("Waiting for authentication channel "+
" confirmation with partner %s", recipientID)
scnt := uint(0)
waitSecs := viper.GetUint("auth-timeout")
for !authConfirmed && scnt < waitSecs {
time.Sleep(1 * time.Second)
scnt++
}
if scnt == waitSecs {
jww.FATAL.Panicf("Could not confirm "+
"authentication channel for %s, "+
"waited %d seconds.", recipientID,
waitSecs)
}
jww.INFO.Printf("Authentication channel confirmation"+
" took %d seconds", waitSecs)
} }
msg := message.Send{ msg := message.Send{
...@@ -187,7 +220,6 @@ var rootCmd = &cobra.Command{ ...@@ -187,7 +220,6 @@ var rootCmd = &cobra.Command{
jww.FATAL.Panicf("%+v", err) jww.FATAL.Panicf("%+v", err)
} }
jww.INFO.Printf("RoundIDs: %+v\n", roundIDs)
time.Sleep(sendDelay * time.Millisecond) time.Sleep(sendDelay * time.Millisecond)
} }
...@@ -217,13 +249,6 @@ var rootCmd = &cobra.Command{ ...@@ -217,13 +249,6 @@ var rootCmd = &cobra.Command{
} }
} }
fmt.Printf("Received %d\n", receiveCnt) fmt.Printf("Received %d\n", receiveCnt)
if receiveCnt == 0 && sendCnt == 0 {
scnt := uint(0)
for num_channels_confirmed == 0 && scnt < waitSecs {
time.Sleep(1 * time.Second)
scnt++
}
}
err = client.StopNetworkFollower(5 * time.Second) err = client.StopNetworkFollower(5 * time.Second)
if err != nil { if err != nil {
jww.WARN.Printf( jww.WARN.Printf(
...@@ -391,14 +416,27 @@ func printChanRequest(requestor contact.Contact, message string) { ...@@ -391,14 +416,27 @@ func printChanRequest(requestor contact.Contact, message string) {
//fmt.Printf(msg) //fmt.Printf(msg)
} }
func addAuthenticatedChannel(client *api.Client, recipientID *id.ID, func addPrecanAuthenticatedChannel(client *api.Client, recipientID *id.ID,
recipient contact.Contact, isPrecanPartner bool) { recipient contact.Contact) {
if client.HasAuthenticatedChannel(recipientID) { jww.WARN.Printf("Precanned user id detected: %s", recipientID)
jww.INFO.Printf("Authenticated channel already in place for %s", preUsr, err := client.MakePrecannedAuthenticatedChannel(
recipientID) getPrecanID(recipientID))
return if err != nil {
jww.FATAL.Panicf("%+v", err)
}
// Sanity check, make sure user id's haven't changed
preBytes := preUsr.ID.Bytes()
idBytes := recipientID.Bytes()
for i := 0; i < len(preBytes); i++ {
if idBytes[i] != preBytes[i] {
jww.FATAL.Panicf("no id match: %v %v",
preBytes, idBytes)
}
}
} }
func addAuthenticatedChannel(client *api.Client, recipientID *id.ID,
recipient contact.Contact) {
var allowed bool var allowed bool
if viper.GetBool("unsafe-channel-creation") { if viper.GetBool("unsafe-channel-creation") {
msg := "unsafe channel creation enabled\n" msg := "unsafe channel creation enabled\n"
...@@ -419,24 +457,7 @@ func addAuthenticatedChannel(client *api.Client, recipientID *id.ID, ...@@ -419,24 +457,7 @@ func addAuthenticatedChannel(client *api.Client, recipientID *id.ID,
recipientContact := recipient recipientContact := recipient
if isPrecanPartner { if recipientContact.ID != nil && recipientContact.DhPubKey != nil {
jww.WARN.Printf("Precanned user id detected: %s",
recipientID)
preUsr, err := client.MakePrecannedAuthenticatedChannel(
getPrecanID(recipientID))
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
// Sanity check, make sure user id's haven't changed
preBytes := preUsr.ID.Bytes()
idBytes := recipientID.Bytes()
for i := 0; i < len(preBytes); i++ {
if idBytes[i] != preBytes[i] {
jww.FATAL.Panicf("no id match: %v %v",
preBytes, idBytes)
}
}
} else if recipientContact.ID != nil && recipientContact.DhPubKey != nil {
me := client.GetUser().GetContact() me := client.GetUser().GetContact()
jww.INFO.Printf("Requesting auth channel from: %s", jww.INFO.Printf("Requesting auth channel from: %s",
recipientID) recipientID)
...@@ -708,16 +729,22 @@ func init() { ...@@ -708,16 +729,22 @@ func init() {
viper.BindPFlag("unsafe-channel-creation", viper.BindPFlag("unsafe-channel-creation",
rootCmd.Flags().Lookup("unsafe-channel-creation")) rootCmd.Flags().Lookup("unsafe-channel-creation"))
rootCmd.Flags().BoolP("assume-auth-channel", "", false,
"Do not check for an authentication channel for this user")
viper.BindPFlag("assume-auth-channel",
rootCmd.Flags().Lookup("assume-auth-channel"))
rootCmd.Flags().BoolP("accept-channel", "", false, rootCmd.Flags().BoolP("accept-channel", "", false,
"Accept the channel request for the corresponding recipient ID") "Accept the channel request for the corresponding recipient ID")
viper.BindPFlag("accept-channel", viper.BindPFlag("accept-channel",
rootCmd.Flags().Lookup("accept-channel")) rootCmd.Flags().Lookup("accept-channel"))
rootCmd.Flags().BoolP("send-auth-request", "", false,
"Send an auth request to the specified destination and wait"+
"for confirmation")
viper.BindPFlag("send-auth-request",
rootCmd.Flags().Lookup("send-auth-request"))
rootCmd.Flags().UintP("auth-timeout", "", 120,
"The number of seconds to wait for an authentication channel"+
"to confirm")
viper.BindPFlag("auth-timeout",
rootCmd.Flags().Lookup("auth-timeout"))
rootCmd.Flags().BoolP("forceHistoricalRounds", "", false, rootCmd.Flags().BoolP("forceHistoricalRounds", "", false,
"Force all rounds to be sent to historical round retrieval") "Force all rounds to be sent to historical round retrieval")
viper.BindPFlag("forceHistoricalRounds", viper.BindPFlag("forceHistoricalRounds",
......
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
) )
// Change this value to set the version for this build // Change this value to set the version for this build
const currentVersion = "2.2.1" const currentVersion = "2.3.0"
func Version() string { func Version() string {
out := fmt.Sprintf("Elixxir Client v%s -- %s\n\n", api.SEMVER, out := fmt.Sprintf("Elixxir Client v%s -- %s\n\n", api.SEMVER,
......
...@@ -23,6 +23,8 @@ type Network struct { ...@@ -23,6 +23,8 @@ type Network struct {
NetworkHealthTimeout time.Duration NetworkHealthTimeout time.Duration
//Number of parallel node registration the client is capable of //Number of parallel node registration the client is capable of
ParallelNodeRegistrations uint ParallelNodeRegistrations uint
//How far back in rounds the network should actually check
KnownRoundsThreshold uint
Rounds Rounds
Messages Messages
...@@ -39,6 +41,7 @@ func GetDefaultNetwork() Network { ...@@ -39,6 +41,7 @@ func GetDefaultNetwork() Network {
NetworkHealthTimeout: 30 * time.Second, NetworkHealthTimeout: 30 * time.Second,
E2EParams: GetDefaultE2ESessionParams(), E2EParams: GetDefaultE2ESessionParams(),
ParallelNodeRegistrations: 8, ParallelNodeRegistrations: 8,
KnownRoundsThreshold: 1500, //5 rounds/sec * 60 sec/min * 5 min
} }
n.Rounds = GetDefaultRounds() n.Rounds = GetDefaultRounds()
n.Messages = GetDefaultMessage() n.Messages = GetDefaultMessage()
......
...@@ -12,9 +12,6 @@ import ( ...@@ -12,9 +12,6 @@ import (
) )
type Rounds struct { type Rounds struct {
// Maximum number of times to attempt to retrieve a round from a gateway
// before giving up on it
MaxAttemptsCheckingARound uint
// Number of historical rounds required to automatically send a historical // Number of historical rounds required to automatically send a historical
// rounds query // rounds query
MaxHistoricalRounds uint MaxHistoricalRounds uint
...@@ -31,11 +28,13 @@ type Rounds struct { ...@@ -31,11 +28,13 @@ type Rounds struct {
// Toggles if historical rounds should always be used // Toggles if historical rounds should always be used
ForceHistoricalRounds bool ForceHistoricalRounds bool
// Maximum number of times a historical round lookup will be attempted
MaxHistoricalRoundsRetries uint
} }
func GetDefaultRounds() Rounds { func GetDefaultRounds() Rounds {
return Rounds{ return Rounds{
MaxAttemptsCheckingARound: 5,
MaxHistoricalRounds: 100, MaxHistoricalRounds: 100,
HistoricalRoundsPeriod: 100 * time.Millisecond, HistoricalRoundsPeriod: 100 * time.Millisecond,
NumMessageRetrievalWorkers: 8, NumMessageRetrievalWorkers: 8,
...@@ -43,5 +42,6 @@ func GetDefaultRounds() Rounds { ...@@ -43,5 +42,6 @@ func GetDefaultRounds() Rounds {
HistoricalRoundsBufferLen: 1000, HistoricalRoundsBufferLen: 1000,
LookupRoundsBufferLen: 2000, LookupRoundsBufferLen: 2000,
ForceHistoricalRounds: false, ForceHistoricalRounds: false,
MaxHistoricalRoundsRetries: 3,
} }
} }
...@@ -13,8 +13,8 @@ import ( ...@@ -13,8 +13,8 @@ import (
"gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/storage/e2e"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"testing" "testing"
"time"
) )
// Smoke test for handleTrigger // Smoke test for handleTrigger
...@@ -57,7 +57,7 @@ func TestHandleConfirm(t *testing.T) { ...@@ -57,7 +57,7 @@ func TestHandleConfirm(t *testing.T) {
Payload: rekey, Payload: rekey,
MessageType: message.KeyExchangeConfirm, MessageType: message.KeyExchangeConfirm,
Sender: bobID, Sender: bobID,
Timestamp: time.Now(), Timestamp: netTime.Now(),
Encryption: message.E2E, Encryption: message.E2E,
} }
......
...@@ -39,7 +39,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte ...@@ -39,7 +39,7 @@ func Start(switchboard *switchboard.Switchboard, sess *storage.Session, net inte
}) })
// start the trigger thread // start the trigger thread
go startTrigger(sess, net, triggerCh, triggerStop.Quit(), params) go startTrigger(sess, net, triggerCh, triggerStop, params)
//register the rekey confirm thread //register the rekey confirm thread
confirmCh := make(chan message.Receive, 100) confirmCh := make(chan message.Receive, 100)
......
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
dh "gitlab.com/elixxir/crypto/diffieHellman" dh "gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"testing" "testing"
"time" "time"
) )
...@@ -74,7 +75,7 @@ func TestFullExchange(t *testing.T) { ...@@ -74,7 +75,7 @@ func TestFullExchange(t *testing.T) {
Payload: rekeyTrigger, Payload: rekeyTrigger,
MessageType: message.KeyExchangeTrigger, MessageType: message.KeyExchangeTrigger,
Sender: exchangeBobId, Sender: exchangeBobId,
Timestamp: time.Now(), Timestamp: netTime.Now(),
Encryption: message.E2E, Encryption: message.E2E,
} }
......
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"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/stoppable"
"gitlab.com/elixxir/client/storage" "gitlab.com/elixxir/client/storage"
"gitlab.com/elixxir/client/storage/e2e" "gitlab.com/elixxir/client/storage/e2e"
ds "gitlab.com/elixxir/comms/network/dataStructures" ds "gitlab.com/elixxir/comms/network/dataStructures"
...@@ -26,20 +27,22 @@ import ( ...@@ -26,20 +27,22 @@ import (
const ( const (
errBadTrigger = "non-e2e trigger from partner %s" errBadTrigger = "non-e2e trigger from partner %s"
errUnknown = "unknown trigger from partner %s" errUnknown = "unknown trigger from partner %s"
errFailed = "Failed to handle rekey trigger: %s"
) )
func startTrigger(sess *storage.Session, net interfaces.NetworkManager, func startTrigger(sess *storage.Session, net interfaces.NetworkManager,
c chan message.Receive, quitCh <-chan struct{}, params params.Rekey) { c chan message.Receive, stop *stoppable.Single, params params.Rekey) {
for true { for true {
select { select {
case <-quitCh: case <-stop.Quit():
return return
case request := <-c: case request := <-c:
go func() {
err := handleTrigger(sess, net, request, params) err := handleTrigger(sess, net, request, params)
if err != nil { if err != nil {
jww.ERROR.Printf("Failed to handle rekey trigger: %s", jww.ERROR.Printf(errFailed, err)
err)
} }
}()
} }
} }
} }
......
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
dh "gitlab.com/elixxir/crypto/diffieHellman" dh "gitlab.com/elixxir/crypto/diffieHellman"
"gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
"testing" "testing"
"time" "time"
...@@ -54,7 +55,7 @@ func TestHandleTrigger(t *testing.T) { ...@@ -54,7 +55,7 @@ func TestHandleTrigger(t *testing.T) {
Payload: rekey, Payload: rekey,
MessageType: message.NoType, MessageType: message.NoType,
Sender: bobID, Sender: bobID,
Timestamp: time.Now(), Timestamp: netTime.Now(),
Encryption: message.E2E, Encryption: message.E2E,
} }
......
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
package keyExchange package keyExchange
import ( import (
"testing"
"time"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces" "gitlab.com/elixxir/client/interfaces"
...@@ -31,6 +28,8 @@ import ( ...@@ -31,6 +28,8 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"gitlab.com/xx_network/primitives/netTime"
"testing"
) )
// Generate partner ID for two people, used for smoke tests // Generate partner ID for two people, used for smoke tests
...@@ -170,7 +169,7 @@ func (t *testNetworkManagerFullExchange) SendE2E(m message.Send, p params.E2E) ( ...@@ -170,7 +169,7 @@ func (t *testNetworkManagerFullExchange) SendE2E(m message.Send, p params.E2E) (
Payload: payload, Payload: payload,
MessageType: message.KeyExchangeConfirm, MessageType: message.KeyExchangeConfirm,
Sender: exchangeAliceId, Sender: exchangeAliceId,
Timestamp: time.Now(), Timestamp: netTime.Now(),
Encryption: message.E2E, Encryption: message.E2E,
} }
......
package network
import (
"container/list"
"crypto/md5"
"gitlab.com/elixxir/client/storage/reception"
"gitlab.com/xx_network/primitives/id"
)
type idFingerprint [16]byte
type checkedRounds struct{
lookup map[idFingerprint]*checklist
}
type checklist struct{
m map[id.Round]interface{}
l *list.List
}
func newCheckedRounds()*checkedRounds{
return &checkedRounds{
lookup: make(map[idFingerprint]*checklist),
}
}
func (cr *checkedRounds)Check(identity reception.IdentityUse, rid id.Round)bool{
idFp := getIdFingerprint(identity)
cl, exists := cr.lookup[idFp]
if !exists{
cl = &checklist{
m: make(map[id.Round]interface{}),
l: list.New().Init(),
}
cr.lookup[idFp]=cl
}
if _, exists := cl.m[rid]; !exists{
cl.m[rid] = nil
cl.l.PushBack(rid)
return true
}
return false
}
func (cr *checkedRounds)Prune(identity reception.IdentityUse, earliestAllowed id.Round){
idFp := getIdFingerprint(identity)
cl, exists := cr.lookup[idFp]
if !exists {
return
}
e := cl.l.Front()
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{
break
}
}
}
func getIdFingerprint(identity reception.IdentityUse)idFingerprint{
h := md5.New()
h.Write(identity.EphId[:])
h.Write(identity.Source[:])
fp := idFingerprint{}
copy(fp[:], h.Sum(nil))
return fp
}
\ No newline at end of file
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"gitlab.com/elixxir/client/storage/versioned" "gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral" "gitlab.com/xx_network/primitives/id/ephemeral"
"gitlab.com/xx_network/primitives/netTime"
"time" "time"
) )
...@@ -59,7 +60,7 @@ func track(session *storage.Session, ourId *id.ID, stop *stoppable.Single) { ...@@ -59,7 +60,7 @@ func track(session *storage.Session, ourId *id.ID, stop *stoppable.Single) {
receptionStore.WaitForIdSizeUpdate() receptionStore.WaitForIdSizeUpdate()
for true { for true {
now := time.Now() now := netTime.Now()
// Generates the IDs since the last track // Generates the IDs since the last track
protoIds, err := ephemeral.GetIdsByRange(ourId, receptionStore.GetIDSize(), protoIds, err := ephemeral.GetIdsByRange(ourId, receptionStore.GetIDSize(),
now, now.Sub(lastCheck)) now, now.Sub(lastCheck))
...@@ -148,7 +149,7 @@ func checkTimestampStore(session *storage.Session) error { ...@@ -148,7 +149,7 @@ func checkTimestampStore(session *storage.Session) error {
if _, err := session.Get(TimestampKey); err != nil { if _, err := session.Get(TimestampKey); err != nil {
// only generate from the last hour because this is a new id, it // only generate from the last hour because this is a new id, it
// couldn't receive messages yet // couldn't receive messages yet
now, err := marshalTimestamp(time.Now().Add(-1 * time.Hour)) now, err := marshalTimestamp(netTime.Now().Add(-1 * time.Hour))
if err != nil { if err != nil {
return errors.Errorf("Could not marshal new timestamp for storage: %v", err) return errors.Errorf("Could not marshal new timestamp for storage: %v", err)
} }
...@@ -161,7 +162,7 @@ func checkTimestampStore(session *storage.Session) error { ...@@ -161,7 +162,7 @@ func checkTimestampStore(session *storage.Session) error {
// Takes the stored timestamp and unmarshal into a time object // Takes the stored timestamp and unmarshal into a time object
func unmarshalTimestamp(lastTimestampObj *versioned.Object) (time.Time, error) { func unmarshalTimestamp(lastTimestampObj *versioned.Object) (time.Time, error) {
if lastTimestampObj == nil || lastTimestampObj.Data == nil { if lastTimestampObj == nil || lastTimestampObj.Data == nil {
return time.Now(), nil return netTime.Now(), nil
} }
lastTimestamp := time.Time{} lastTimestamp := time.Time{}
...@@ -175,7 +176,7 @@ func marshalTimestamp(timeToStore time.Time) (*versioned.Object, error) { ...@@ -175,7 +176,7 @@ func marshalTimestamp(timeToStore time.Time) (*versioned.Object, error) {
return &versioned.Object{ return &versioned.Object{
Version: 0, Version: 0,
Timestamp: time.Now(), Timestamp: netTime.Now(),
Data: data, Data: data,
}, err }, err
} }
......
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
"gitlab.com/xx_network/comms/signature" "gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"gitlab.com/xx_network/primitives/utils" "gitlab.com/xx_network/primitives/utils"
"testing" "testing"
"time" "time"
...@@ -31,7 +32,7 @@ func TestCheck(t *testing.T) { ...@@ -31,7 +32,7 @@ func TestCheck(t *testing.T) {
} }
/// Store a mock initial timestamp the store /// Store a mock initial timestamp the store
now := time.Now() now := netTime.Now()
twoDaysAgo := now.Add(-2 * 24 * time.Hour) twoDaysAgo := now.Add(-2 * 24 * time.Hour)
twoDaysTimestamp, err := marshalTimestamp(twoDaysAgo) twoDaysTimestamp, err := marshalTimestamp(twoDaysAgo)
if err != nil { if err != nil {
...@@ -65,7 +66,7 @@ func TestCheck_Thread(t *testing.T) { ...@@ -65,7 +66,7 @@ func TestCheck_Thread(t *testing.T) {
stop := stoppable.NewSingle(ephemeralStoppable) stop := stoppable.NewSingle(ephemeralStoppable)
/// Store a mock initial timestamp the store /// Store a mock initial timestamp the store
now := time.Now() now := netTime.Now()
yesterday := now.Add(-24 * time.Hour) yesterday := now.Add(-24 * time.Hour)
yesterdayTimestamp, err := marshalTimestamp(yesterday) yesterdayTimestamp, err := marshalTimestamp(yesterday)
if err != nil { if err != nil {
......
...@@ -40,7 +40,6 @@ import ( ...@@ -40,7 +40,6 @@ import (
) )
const debugTrackPeriod = 1 * time.Minute const debugTrackPeriod = 1 * time.Minute
const maxChecked = 100000
//comms interface makes testing easier //comms interface makes testing easier
type followNetworkComms interface { type followNetworkComms interface {
...@@ -241,26 +240,53 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source, ...@@ -241,26 +240,53 @@ func (m *manager) follow(report interfaces.ClientErrorReport, rng csprng.Source,
// are messages waiting in rounds and then sends signals to the appropriate // are messages waiting in rounds and then sends signals to the appropriate
// handling threads // handling threads
roundChecker := func(rid id.Round) bool { roundChecker := func(rid id.Round) bool {
return m.round.Checker(rid, filterList, identity) return rounds.Checker(rid, filterList)
} }
// move the earliest unknown round tracker forward to the earliest // move the earliest unknown round tracker forward to the earliest
// tracked round if it is behind // tracked round if it is behind
earliestTrackedRound := id.Round(pollResp.EarliestRound) earliestTrackedRound := id.Round(pollResp.EarliestRound)
updated := identity.UR.Set(earliestTrackedRound) updated, _ := identity.ER.Set(earliestTrackedRound)
// loop through all rounds the client does not know about and the gateway // loop through all rounds the client does not know about and the gateway
// does, checking the bloom filter for the user to see if there are // does, checking the bloom filter for the user to see if there are
// messages for the user (bloom not implemented yet) // messages for the user (bloom not implemented yet)
earliestRemaining := gwRoundsState.RangeUnchecked(updated, //threshold is the earliest round that will not be excluded from earliest remaining
maxChecked, roundChecker) earliestRemaining, roundsWithMessages, roundsUnknown := gwRoundsState.RangeUnchecked(updated,
identity.UR.Set(earliestRemaining) m.param.KnownRoundsThreshold, roundChecker)
jww.INFO.Printf("Earliest Remaining: %d", earliestRemaining) _, changed := identity.ER.Set(earliestRemaining)
if changed{
jww.TRACE.Printf("External returns of RangeUnchecked: %d, %v, %v", earliestRemaining, roundsWithMessages, roundsUnknown)
jww.INFO.Printf("New Earliest Remaining: %d", earliestRemaining)
}
roundsWithMessages2 := identity.UR.Iterate(func(rid id.Round)bool{
if gwRoundsState.Checked(rid){
return rounds.Checker(rid, filterList)
}
return false
}, roundsUnknown)
//delete any old rounds from processing for _, rid := range roundsWithMessages{
if earliestRemaining > updated { if m.checked.Check(identity, rid){
for i := updated; i <= earliestRemaining; i++ { m.round.GetMessagesFromRound(rid, identity)
m.round.DeleteProcessingRoundDelete(i, identity.EphId, identity.Source)
} }
} }
for _, rid := range roundsWithMessages2{
m.round.GetMessagesFromRound(rid, identity)
}
earliestToKeep := getEarliestToKeep(m.param.KnownRoundsThreshold,
gwRoundsState.GetLastChecked())
m.checked.Prune(identity, earliestToKeep)
}
func getEarliestToKeep(delta uint, lastchecked id.Round)id.Round{
if uint(lastchecked)<delta{
return 0
}
return lastchecked - id.Round(delta)
} }
...@@ -54,6 +54,9 @@ type manager struct { ...@@ -54,6 +54,9 @@ type manager struct {
//map of polls for debugging //map of polls for debugging
tracker *pollTracker tracker *pollTracker
//tracks already checked rounds
checked *checkedRounds
} }
// NewManager builds a new reception manager object using inputted key fields // NewManager builds a new reception manager object using inputted key fields
...@@ -80,6 +83,7 @@ func NewManager(session *storage.Session, switchboard *switchboard.Switchboard, ...@@ -80,6 +83,7 @@ func NewManager(session *storage.Session, switchboard *switchboard.Switchboard,
param: params, param: params,
running: &running, running: &running,
tracker: newPollTracker(), tracker: newPollTracker(),
checked: newCheckedRounds(),
} }
m.Internal = internal.Internal{ m.Internal = internal.Internal{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment