Documentation
¶
Index ¶
- func CreateIdentityFromSolanaKey(privateKeyBase58 string) (crypto.PrivKey, peer.ID, error)
- func CreatePeerIDFromSolanaPublicKey(solanaPublicKey solana.PublicKey) (peer.ID, error)
- func ExtractSolanaPublicKey(privateKeyBase58 string) (solana.PublicKey, error)
- func PeerIDToSolanaPublicKey(peerID peer.ID) (solana.PublicKey, error)
- type AuthorizationCache
- type BootstrapNode
- type Config
- type Event
- type GetAuthorizedWalletsFunc
- type GetBootstrapNodesFunc
- type ListenPorts
- type LiveKitLogger
- type Logger
- type PubSubHandler
- type SolanaRegistryGater
- func (g *SolanaRegistryGater) ClearCache()
- func (g *SolanaRegistryGater) InterceptAccept(network.ConnMultiaddrs) bool
- func (g *SolanaRegistryGater) InterceptAddrDial(p peer.ID, m multiaddr.Multiaddr) bool
- func (g *SolanaRegistryGater) InterceptPeerDial(p peer.ID) bool
- func (g *SolanaRegistryGater) InterceptSecured(direction network.Direction, p peer.ID, connMultiaddr network.ConnMultiaddrs) bool
- func (g *SolanaRegistryGater) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason)
- func (g *SolanaRegistryGater) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateIdentityFromSolanaKey ¶
CreateIdentityFromSolanaKey converts a Base58-encoded Solana private key to libp2p identity
func CreatePeerIDFromSolanaPublicKey ¶
CreatePeerIDFromSolanaPublicKey creates a libp2p peer ID from a Solana public key
func ExtractSolanaPublicKey ¶
ExtractSolanaPublicKey extracts the Solana public key from a Base58 private key
Types ¶
type AuthorizationCache ¶
type AuthorizationCache struct {
// contains filtered or unexported fields
}
AuthorizationCache provides caching for authorized wallets
type BootstrapNode ¶
type BootstrapNode struct {
PublicKey solana.PublicKey // Node's Solana public key
IP string // IP address
QUICPort int // QUIC port
TCPPort int // TCP port
}
BootstrapNode represents information about a bootstrap node
type Config ¶
type Config struct {
WalletPrivateKey string // Base58-encoded Solana private key
DatabaseName string // Namespace for topics
GetAuthorizedWallets GetAuthorizedWalletsFunc // Function to get authorized wallets
GetBootstrapNodes GetBootstrapNodesFunc // Function to get bootstrap nodes
Logger Logger // Logger for all internal operations
ListenPorts ListenPorts // Ports for different transports
RefreshInterval time.Duration // How often to refresh authorized wallets cache (default: 30s)
Debug bool // Enable debug logging for p2p operations
SkipBootstrapWait bool // Skip waiting for bootstrap nodes (useful for tests)
}
Config represents the configuration for connecting to the P2P pubsub network
type Event ¶
type Event struct {
ID string `json:"id"` // Unique event identifier
FromPeerId string `json:"from_peer"` // Peer ID of sender
Message interface{} `json:"message"` // The actual message content
Timestamp int64 `json:"timestamp"` // Unix timestamp
}
Event represents a message in the pub/sub system
type GetAuthorizedWalletsFunc ¶
Function provided by node software to get authorized wallets
type GetBootstrapNodesFunc ¶
type GetBootstrapNodesFunc func(ctx context.Context) ([]BootstrapNode, error)
Function provided by node software to get bootstrap nodes
type ListenPorts ¶
type ListenPorts struct {
QUIC int // QUIC listen port (default: 4001)
TCP int // TCP listen port (default: 4002)
}
ListenPorts represents ports for different transports
type LiveKitLogger ¶
type LiveKitLogger interface {
Debugw(msg string, keysAndValues ...interface{})
Infow(msg string, keysAndValues ...interface{})
Warnw(msg string, err error, keysAndValues ...interface{})
Errorw(msg string, err error, keysAndValues ...interface{})
}
LiveKitLogger defines the interface expected by LiveKit logging with keyed logging methods ending in 'w' (Debugw, Infow, etc.)
type Logger ¶
type Logger interface {
Debug(msg string, keysAndValues ...interface{})
Info(msg string, keysAndValues ...interface{})
Warn(msg string, keysAndValues ...interface{})
Error(msg string, keysAndValues ...interface{})
}
Logger interface for structured logging (library-agnostic)
func NewLivekitLoggerAdapter ¶
func NewLivekitLoggerAdapter(logger LiveKitLogger) Logger
NewLivekitLoggerAdapter creates a logger adapter for LiveKit loggers LiveKit loggers typically use methods like Debugw, Infow, Warnw, Errorw that accept keyed logging with variadic key-value pairs
func NewSlogLogger ¶
NewSlogLogger creates a logger using Go's standard slog (recommended for Go 1.23.11+)
type PubSubHandler ¶
type PubSubHandler func(Event)
PubSubHandler is the callback function for handling received messages
type SolanaRegistryGater ¶
type SolanaRegistryGater struct {
// contains filtered or unexported fields
}
SolanaRegistryGater implements connection gating based on Solana wallet registry
func NewSolanaRegistryGater ¶
func NewSolanaRegistryGater(getAuthorizedWallets GetAuthorizedWalletsFunc, logger Logger, refreshInterval time.Duration) *SolanaRegistryGater
NewSolanaRegistryGater creates a new connection gater with the provided registry function
func (*SolanaRegistryGater) ClearCache ¶
func (g *SolanaRegistryGater) ClearCache()
ClearCache clears the authorization cache (useful for testing)
func (*SolanaRegistryGater) InterceptAccept ¶
func (g *SolanaRegistryGater) InterceptAccept(network.ConnMultiaddrs) bool
InterceptAccept validates incoming connections (initial filter)
func (*SolanaRegistryGater) InterceptAddrDial ¶
InterceptAddrDial validates specific address connections
func (*SolanaRegistryGater) InterceptPeerDial ¶
func (g *SolanaRegistryGater) InterceptPeerDial(p peer.ID) bool
InterceptPeerDial validates outgoing connections against registry
func (*SolanaRegistryGater) InterceptSecured ¶
func (g *SolanaRegistryGater) InterceptSecured(direction network.Direction, p peer.ID, connMultiaddr network.ConnMultiaddrs) bool
InterceptSecured performs post-handshake authorization via wallet registry lookup
func (*SolanaRegistryGater) InterceptUpgraded ¶
func (g *SolanaRegistryGater) InterceptUpgraded(network.Conn) (allow bool, reason control.DisconnectReason)
InterceptUpgraded validates connections after protocol upgrade (no additional checks needed)
func (*SolanaRegistryGater) Stop ¶
func (g *SolanaRegistryGater) Stop()
Stop stops the background refresh process