Add Emberwake Cloud Ecosystem deploy hub with AWS and generic spread templates.
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
Unified expandable panels with mermaid flows, ZIP export, connection tests, and Playwright smoke coverage.
This commit is contained in:
42
agent/deploy/shard_gossip.go
Normal file
42
agent/deploy/shard_gossip.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func FormatShardAdvert(region string, shardIndex int) string {
|
||||
return fmt.Sprintf("%s:%d", strings.TrimSpace(region), shardIndex)
|
||||
}
|
||||
|
||||
func ParseShardAdvert(advert string) (region string, index int, ok bool) {
|
||||
advert = strings.TrimSpace(advert)
|
||||
colon := strings.LastIndex(advert, ":")
|
||||
if colon <= 0 {
|
||||
return "", 0, false
|
||||
}
|
||||
region = strings.TrimSpace(advert[:colon])
|
||||
if _, err := fmt.Sscanf(strings.TrimSpace(advert[colon+1:]), "%d", &index); err != nil {
|
||||
return "", 0, false
|
||||
}
|
||||
return region, index, region != ""
|
||||
}
|
||||
|
||||
func ResolveLocalAWSRegion(policyFallback string) string {
|
||||
if meta := ReadEC2InstanceMeta(); strings.TrimSpace(meta.Region) != "" {
|
||||
return strings.TrimSpace(meta.Region)
|
||||
}
|
||||
return strings.TrimSpace(policyFallback)
|
||||
}
|
||||
|
||||
func cloudFrontShardURL(domain, token, region string, index int, shardHash string) string {
|
||||
domain = strings.TrimRight(strings.TrimSpace(domain), "/")
|
||||
shardHash = strings.TrimSpace(strings.ToLower(shardHash))
|
||||
if domain == "" || token == "" || region == "" || shardHash == "" {
|
||||
return ""
|
||||
}
|
||||
if !strings.HasPrefix(domain, "http") {
|
||||
domain = "https://" + domain
|
||||
}
|
||||
return fmt.Sprintf("%s/shards/%s/%s/%d-%s.bin", domain, token, region, index, shardHash)
|
||||
}
|
||||
Reference in New Issue
Block a user