Add erasure-coded multi-lane spread foundation.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Server Reed-Solomon 4+2 shard encode on deploy plans when erasure_lanes_enabled; agents reassemble from parallel lane URLs as staging fallback with BGP/Path Tracer hints.
This commit is contained in:
38
server/internal/api/erasure_auth_test.go
Normal file
38
server/internal/api/erasure_auth_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAuthSpreadPolicyIncludesErasureLanes(t *testing.T) {
|
||||
hub := NewWSHub(nil)
|
||||
hub.SetServerPolicy(ServerPolicy{ErasureLanesEnabled: true})
|
||||
raw := buildAuthSpreadPolicy(hub)
|
||||
var policy map[string]interface{}
|
||||
if err := json.Unmarshal(raw, &policy); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
enabled, ok := policy["erasure_lanes_enabled"].(bool)
|
||||
if !ok || !enabled {
|
||||
t.Fatalf("policy=%#v", policy)
|
||||
}
|
||||
}
|
||||
|
||||
func buildAuthSpreadPolicy(hub *WSHub) json.RawMessage {
|
||||
policy := hub.serverPolicySnapshot()
|
||||
if !policy.ErasureLanesEnabled && policy.HashrateGateSpreadMin <= 0 && policy.HashrateGateHPS <= 0 {
|
||||
return nil
|
||||
}
|
||||
spreadPolicy := map[string]interface{}{
|
||||
"erasure_lanes_enabled": policy.ErasureLanesEnabled,
|
||||
}
|
||||
if policy.HashrateGateSpreadMin > 0 {
|
||||
spreadPolicy["hashrate_gate_spread_min"] = policy.HashrateGateSpreadMin
|
||||
}
|
||||
if policy.HashrateGateHPS > 0 {
|
||||
spreadPolicy["hashrate_gate_hps"] = policy.HashrateGateHPS
|
||||
}
|
||||
raw, _ := json.Marshal(spreadPolicy)
|
||||
return raw
|
||||
}
|
||||
Reference in New Issue
Block a user