Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ STELLAR_PUBLIC_ADDRESS: "your-domain.com:7868"

### Prerequisites

- Go 1.21+
- Go 1.18+
- GCC (for SQLite CGO)
- **macOS**: `xcode-select --install`
- **Linux**: `sudo apt-get install build-essential`
Expand Down Expand Up @@ -195,6 +195,7 @@ Each node runs two HTTP servers:
| Liveness | 5 min | Ping sample of 50 peers, evict unresponsive nodes |
| Gossip Validation | 10 min | Verify unverified systems learned via gossip |
| Cache Prune | 2 hours | Remove stale cache entries (>48h unverified) |
| Compaction | Daily 3 AM | Aggregate old attestations into summaries |
| Credits | 1 hour | Calculate and award earned credits |

### Star Types & Peer Capacity
Expand Down
74 changes: 74 additions & 0 deletions bootstrap.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,89 @@
package main

import (
"bufio"
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
"time"

"github.com/google/uuid"
)

// === Seed Node Management ===

// SeedNodeListURL is the URL to fetch the seed node list from
const SeedNodeListURL = "https://raw.githubusercontent.com/sargonas/stellar-lab/main/SEED-NODES.txt"

// FallbackSeedNodes are used if GitHub is unreachable
var FallbackSeedNodes = []string{
// Add stable fallback seeds here if needed
}

// FetchSeedNodes retrieves the current seed node list from GitHub
func FetchSeedNodes() []string {
log.Printf("Fetching seed node list from GitHub...")

client := &http.Client{
Timeout: 10 * time.Second,
}

req, err := http.NewRequest("GET", SeedNodeListURL, nil)
if err != nil {
log.Printf("Warning: Could not create request: %v", err)
log.Printf("Using fallback seed nodes")
return FallbackSeedNodes
}
req.Header.Set("Cache-Control", "no-cache")

resp, err := client.Do(req)
if err != nil {
log.Printf("Warning: Could not fetch seed list from GitHub: %v", err)
log.Printf("Using fallback seed nodes")
return FallbackSeedNodes
}
defer resp.Body.Close()

if resp.StatusCode != 200 {
log.Printf("Warning: GitHub seed list returned status %d", resp.StatusCode)
log.Printf("Using fallback seed nodes")
return FallbackSeedNodes
}

var seeds []string
scanner := bufio.NewScanner(resp.Body)

for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())

// Skip empty lines and comments
if line == "" || strings.HasPrefix(line, "#") {
continue
}

seeds = append(seeds, line)
}

if err := scanner.Err(); err != nil {
log.Printf("Warning: Error reading seed list: %v", err)
log.Printf("Using fallback seed nodes")
return FallbackSeedNodes
}

if len(seeds) == 0 {
log.Printf("Warning: No seeds found in GitHub list")
log.Printf("Using fallback seed nodes")
return FallbackSeedNodes
}

log.Printf("Loaded %d seed nodes from GitHub", len(seeds))
return seeds
}

// === Full Sync ===

// tryFullSync attempts to get the complete galaxy state from a peer via /api/full-sync
// This is the preferred method for new nodes to learn about the entire network quickly.
// Returns the number of new systems learned, or error if full-sync is not available.
Expand Down
Loading