Add NIP-11 relay synchronization and group management features
- Introduced a new `sync` package for managing NIP-11 relay information and relay group configurations. - Implemented a cache for NIP-11 documents, allowing retrieval of relay public keys and authoritative configurations. - Enhanced the sync manager to update peer lists based on authoritative configurations from relay group events. - Updated event handling to incorporate policy checks during event imports, ensuring compliance with relay rules. - Refactored various components to utilize the new `sha256-simd` package for improved performance. - Added comprehensive tests to validate the new synchronization and group management functionalities. - Bumped version to v0.24.1 to reflect these changes.
This commit is contained in:
18
app/main.go
18
app/main.go
@@ -117,8 +117,22 @@ func Run(
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize relay group manager
|
||||
l.relayGroupMgr = dsync.NewRelayGroupManager(db, cfg.RelayGroupAdmins)
|
||||
|
||||
// Initialize sync manager if relay peers are configured
|
||||
var peers []string
|
||||
if len(cfg.RelayPeers) > 0 {
|
||||
peers = cfg.RelayPeers
|
||||
} else {
|
||||
// Try to get peers from relay group configuration
|
||||
if config, err := l.relayGroupMgr.FindAuthoritativeConfig(ctx); err == nil && config != nil {
|
||||
peers = config.Relays
|
||||
log.I.F("using relay group configuration with %d peers", len(peers))
|
||||
}
|
||||
}
|
||||
|
||||
if len(peers) > 0 {
|
||||
// Get relay identity for node ID
|
||||
sk, err := db.GetOrCreateRelayIdentitySecret()
|
||||
if err != nil {
|
||||
@@ -132,8 +146,8 @@ func Run(
|
||||
if relayURL == "" {
|
||||
relayURL = fmt.Sprintf("http://localhost:%d", cfg.Port)
|
||||
}
|
||||
l.syncManager = dsync.NewManager(ctx, db, nodeID, relayURL, cfg.RelayPeers)
|
||||
log.I.F("distributed sync manager initialized with %d peers", len(cfg.RelayPeers))
|
||||
l.syncManager = dsync.NewManager(ctx, db, nodeID, relayURL, peers, l.relayGroupMgr, l.policyManager)
|
||||
log.I.F("distributed sync manager initialized with %d peers", len(peers))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user