Documentation
¶
Overview ¶
Package distributed provides serial-based peer-to-peer synchronization
Index ¶
- type Config
- type CurrentRequest
- type CurrentResponse
- type EventIDsRequest
- type EventIDsResponse
- type Manager
- func (m *Manager) GetCurrentSerial() uint64
- func (m *Manager) GetEventsWithIDs(from, to uint64) (map[string]uint64, error)
- func (m *Manager) GetNodeID() string
- func (m *Manager) GetPeerPubkey(peerURL string) (string, error)
- func (m *Manager) GetPeerStatus() map[string]uint64
- func (m *Manager) GetPeers() []string
- func (m *Manager) GetRelayURL() string
- func (m *Manager) HandleCurrentRequest(w http.ResponseWriter, r *http.Request)
- func (m *Manager) HandleEventIDsRequest(w http.ResponseWriter, r *http.Request)
- func (m *Manager) IsAuthorizedPeer(peerURL string, expectedPubkey string) bool
- func (m *Manager) IsSelfNodeID(nodeID string) bool
- func (m *Manager) IsSelfURL(url string) bool
- func (m *Manager) MarkSelfURL(url string)
- func (m *Manager) NotifyNewEvent(eventID []byte, serial uint64)
- func (m *Manager) Stop()
- func (m *Manager) UpdatePeers(newPeers []string)
- func (m *Manager) UpdateSerial()
- type PolicyChecker
- type RelayGroupConfigProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
NodeID string
RelayURL string
Peers []string
SyncInterval time.Duration
NIP11CacheTTL time.Duration
}
Config holds configuration for the distributed sync manager
type CurrentRequest ¶
CurrentRequest represents a request for the current serial number
type CurrentResponse ¶
type CurrentResponse struct {
NodeID string `json:"node_id"`
RelayURL string `json:"relay_url"`
Serial uint64 `json:"serial"`
}
CurrentResponse returns the current serial number
type EventIDsRequest ¶
type EventIDsRequest struct {
NodeID string `json:"node_id"`
RelayURL string `json:"relay_url"`
From uint64 `json:"from"`
To uint64 `json:"to"`
}
EventIDsRequest represents a request for event IDs with serials
type EventIDsResponse ¶
type EventIDsResponse struct {
EventMap map[string]uint64 `json:"event_map"` // event_id -> serial
}
EventIDsResponse contains event IDs mapped to their serial numbers
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles distributed synchronization between relay peers using serial numbers as clocks
func NewManager ¶
func NewManager(ctx context.Context, db *database.D, cfg *Config, policyManager PolicyChecker) *Manager
NewManager creates a new sync manager
func (*Manager) GetCurrentSerial ¶
GetCurrentSerial returns the current serial number
func (*Manager) GetEventsWithIDs ¶
GetEventsWithIDs retrieves events with their IDs by serial range
func (*Manager) GetNodeID ¶
GetNodeID returns the node's identity
func (*Manager) GetPeerPubkey ¶
GetPeerPubkey fetches and caches the pubkey for a peer relay
func (*Manager) GetPeerStatus ¶
GetPeerStatus returns the sync status for all peers
func (*Manager) GetPeers ¶
GetPeers returns a copy of the current peer list
func (*Manager) GetRelayURL ¶
GetRelayURL returns the relay's URL
func (*Manager) HandleCurrentRequest ¶
func (m *Manager) HandleCurrentRequest(w http.ResponseWriter, r *http.Request)
HandleCurrentRequest handles requests for current serial number
func (*Manager) HandleEventIDsRequest ¶
func (m *Manager) HandleEventIDsRequest(w http.ResponseWriter, r *http.Request)
HandleEventIDsRequest handles requests for event IDs with their serial numbers
func (*Manager) IsAuthorizedPeer ¶
IsAuthorizedPeer checks if a peer is authorized by validating its NIP-11 pubkey
func (*Manager) IsSelfNodeID ¶
IsSelfNodeID checks if a node ID matches ours
func (*Manager) IsSelfURL ¶
IsSelfURL checks if a URL is our own relay
func (*Manager) MarkSelfURL ¶
MarkSelfURL marks a URL as belonging to us
func (*Manager) NotifyNewEvent ¶
NotifyNewEvent notifies the manager of a new event
func (*Manager) UpdatePeers ¶
UpdatePeers updates the peer list from relay group configuration
Source Files
¶
- manager.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grpc provides a gRPC client for the distributed sync service.
|
Package grpc provides a gRPC client for the distributed sync service. |
|
Package server provides the gRPC server implementation for distributed sync.
|
Package server provides the gRPC server implementation for distributed sync. |