diff --git a/bindings/client.go b/bindings/client.go index 6eafdc35a03be94ad9cfa547f5a0054f60072230..33ef281983799bab25a50663a71b151749ba3535 100644 --- a/bindings/client.go +++ b/bindings/client.go @@ -18,6 +18,7 @@ import ( "gitlab.com/elixxir/crypto/contact" "gitlab.com/elixxir/primitives/states" "gitlab.com/xx_network/primitives/id" + "gitlab.com/xx_network/primitives/netTime" "sync" "time" ) @@ -25,6 +26,8 @@ import ( var extantClient bool var loginMux sync.Mutex +var clientSingleton *Client + // sets the log level func init() { jww.SetLogThreshold(jww.LevelInfo) @@ -96,7 +99,15 @@ func Login(storageDir string, password []byte, parameters string) (*Client, erro return nil, errors.New(fmt.Sprintf("Failed to login: %+v", err)) } extantClient = true - return &Client{api: *client}, nil + clientSingleton := &Client{api: *client} + return clientSingleton, nil +} + +// returns a previously created client. IF be used if the garbage collector +// removes the client instance on the app side. Is NOT thread safe relative to +// login, newClient, or newPrecannedClient +func GetClientSingleton() *Client { + return clientSingleton } // sets level of logging. All logs the set level and above will be displayed @@ -219,9 +230,9 @@ func (c *Client) StopNetworkFollower(timeoutMS int) error { // WaitForNewtwork will block until either the network is healthy or the // passed timeout. It will return true if the network is healthy func (c *Client) WaitForNetwork(timeoutMS int) bool { - start := time.Now() + start := netTime.Now() timeout := time.Duration(timeoutMS) * time.Millisecond - for time.Now().Sub(start) < timeout { + for netTime.Now().Sub(start) < timeout { if c.api.GetHealth().IsHealthy() { return true } diff --git a/go.mod b/go.mod index 51bfe03d5052419d82449659ea022222810956e6..c6234ea8322579e76604ee872b1410839c3b6eb0 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/viper v1.7.1 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 - gitlab.com/elixxir/comms v0.0.4-0.20210505205202-1d4c18a7fcb2 + gitlab.com/elixxir/comms v0.0.4-0.20210506161214-6371db79ce6f gitlab.com/elixxir/crypto v0.0.7-0.20210504210535-3077ddf9984d gitlab.com/elixxir/ekv v0.1.5 gitlab.com/elixxir/primitives v0.0.3-0.20210504210415-34cf31c2816e diff --git a/go.sum b/go.sum index 66c94444d1f09acedd0d041ddffaac1c0285233b..e07685770c61db52aa8e701d5040959f292fcbf5 100644 --- a/go.sum +++ b/go.sum @@ -255,6 +255,8 @@ gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228 h1:Gi6rj4mAlK0 gitlab.com/elixxir/bloomfilter v0.0.0-20200930191214-10e9ac31b228/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= gitlab.com/elixxir/comms v0.0.4-0.20210505205202-1d4c18a7fcb2 h1:8aL4V7FaKkDb5iPdJ1rlFFhrHrLWUtbmBjw4BysXzEA= gitlab.com/elixxir/comms v0.0.4-0.20210505205202-1d4c18a7fcb2/go.mod h1:VN0fNE7GFMrkZwRGnqA7fNNRAXDA4CCP6su/FQQ68RI= +gitlab.com/elixxir/comms v0.0.4-0.20210506161214-6371db79ce6f h1:0hvU+6Y+JGFnBu8ZSMk0ukNuYg+GAnVKD8Yo4VwSdao= +gitlab.com/elixxir/comms v0.0.4-0.20210506161214-6371db79ce6f/go.mod h1:7ff+A4Nom55mKiRW7qWsN7LDjGay4OZwiaaIVXZ4hdk= 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.3 h1:znCt/x2bL4y8czTPaaFkwzdgSgW3BJc/1+dxyf1jqVw= diff --git a/network/ephemeral/tracker.go b/network/ephemeral/tracker.go index 41d67012f2242241089e87724a73e460d0e62f81..7292f73d8cfa8741c4bac631dd9c43ab3859b53d 100644 --- a/network/ephemeral/tracker.go +++ b/network/ephemeral/tracker.go @@ -63,7 +63,7 @@ func track(session *storage.Session, ourId *id.ID, stop *stoppable.Single) { now := netTime.Now() //hack for inconsistent time on android - if lastCheck.Sub(now) <=0{ + if now.Sub(lastCheck) <=0{ now = lastCheck.Add(time.Nanosecond) } diff --git a/network/gateway/hostPool.go b/network/gateway/hostPool.go index 15545f5e7116ac09b52b216add2526f5b7e51f2e..305cc4ea1d111a7cf9c01eff94814ff59c98a2a0 100644 --- a/network/gateway/hostPool.go +++ b/network/gateway/hostPool.go @@ -80,7 +80,7 @@ func DefaultPoolParams() PoolParams { p.HostParams.EnableCoolOff = true p.HostParams.NumSendsBeforeCoolOff = 1 p.HostParams.CoolOffTimeout = 5 * time.Minute - p.HostParams.SendTimeout = 2 * time.Second + p.HostParams.SendTimeout = 3500*time.Millisecond return p }