fix(proxy): reset login activity timer
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
f0477b9980
commit
78e740add7
3 changed files with 11 additions and 0 deletions
|
|
@ -213,6 +213,7 @@ func (m *Miner) handleLogin(request minerRequest) {
|
|||
m.events.Dispatch(Event{Type: EventLogin, Miner: m})
|
||||
}
|
||||
|
||||
m.Touch()
|
||||
if m.State() == MinerStateClosing {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,12 @@ func TestMiner_Login_Good(t *testing.T) {
|
|||
defer clientConn.Close()
|
||||
|
||||
miner := NewMiner(serverConn, 3333, nil)
|
||||
before := miner.LastActivityAt()
|
||||
miner.Start()
|
||||
defer miner.Close()
|
||||
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
|
||||
encoder := json.NewEncoder(clientConn)
|
||||
if err := encoder.Encode(map[string]interface{}{
|
||||
"id": 1,
|
||||
|
|
@ -45,6 +48,9 @@ func TestMiner_Login_Good(t *testing.T) {
|
|||
if response["jsonrpc"] != "2.0" {
|
||||
t.Fatalf("unexpected response: %#v", response)
|
||||
}
|
||||
if !miner.LastActivityAt().After(before) {
|
||||
t.Fatalf("expected login to refresh last activity timestamp, got before=%s after=%s", before, miner.LastActivityAt())
|
||||
}
|
||||
|
||||
result := response["result"].(map[string]interface{})
|
||||
id, _ := result["id"].(string)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package proxy
|
|||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -15,6 +16,9 @@ type splitterShutdown interface {
|
|||
//
|
||||
// p, errorValue := proxy.New(config)
|
||||
func New(config *Config) (*Proxy, error) {
|
||||
if config == nil {
|
||||
return nil, errors.New("config is nil")
|
||||
}
|
||||
if errorValue := config.Validate(); errorValue != nil {
|
||||
return nil, errorValue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue