Artifact f56f856f2fe1ecd638da9c725ae0b1775a45802b1cc31de4fd59e3d1a520b048:
- File
leaf/agent/peer_registry.go
— part of check-in
[eda7960b81]
at
2026-04-23 19:23:42
on branch trunk
— rename module to github.com/danmestas/EdgeSync
Fix the case-sensitive module path to match the actual GitHub repo URL (danmestas/EdgeSync). Remove tracked leaf/leaf binary and ignore .claude/skills/ scratchpad dirs. (user: [email protected], size: 1479) [annotate] [blame] [check-ins using] [more...]
package agent import ( "fmt" "runtime" "strings" ) var buildVersion = "dev" // ensurePeerRegistry creates the peer_registry table if it doesn't exist. func (a *Agent) ensurePeerRegistry() error { _, err := a.repo.DB().Exec(`CREATE TABLE IF NOT EXISTS peer_registry ( peer_id TEXT PRIMARY KEY, last_sync INTEGER, repo_hash TEXT, version TEXT, platform TEXT, capabilities TEXT, nats_subject TEXT, addr TEXT, mtime INTEGER DEFAULT 0 )`) if err != nil { return fmt.Errorf("ensurePeerRegistry: %w", err) } return nil } func (a *Agent) seedPeerRegistry() error { return a.upsertPeerRow() } func (a *Agent) updatePeerRegistryAfterSync() error { return a.upsertPeerRow() } func (a *Agent) upsertPeerRow() error { now := a.clock.Now().Unix() _, err := a.repo.DB().Exec(`INSERT OR REPLACE INTO peer_registry (peer_id, last_sync, repo_hash, version, platform, capabilities, nats_subject, addr, mtime) VALUES (?, ?, '', ?, ?, ?, ?, ?, ?)`, a.config.PeerID, now, buildVersion, runtime.GOOS+"/"+runtime.GOARCH, strings.Join(a.capabilities(), ","), a.config.SubjectPrefix, a.config.ServeHTTPAddr, now, ) return err } func (a *Agent) capabilities() []string { var caps []string if a.config.ServeHTTPAddr != "" { caps = append(caps, "serve-http") } if a.config.ServeNATSEnabled { caps = append(caps, "serve-nats") } if a.config.IrohEnabled { caps = append(caps, "serve-iroh") } caps = append(caps, "push", "pull") return caps }