Documentation
¶
Index ¶
- Constants
- func BuildErrorMessage(message string, err error) types.ErrorMessage
- func BuildResponseMessage(response bool, message ...string) types.ResponseMessage
- func ClaimOwnership(ctx context.Context, connectionManager ConnectionManager, connectionID string, ...) (*types.ResponseMessage, error)
- func ClaimOwnershipAll(ctx context.Context, connectionManager ConnectionManager, root string, ...) map[string]*ClaimOwnershipResult
- func DownloadDag(ctx context.Context, connectionManager ConnectionManager, connectionID string, ...) (context.Context, *types.DagData, error)
- func QueryDag(ctx context.Context, connectionManager ConnectionManager, connectionID string, ...) ([]string, error)
- func QueryEvents(ctx context.Context, connectionManager ConnectionManager, connectionID string, ...) ([]nostr.Event, error)
- func ReadEnvelopeFromStream(stream types.Stream, timeoutDuration time.Duration) (*types.MessageEnvelope, error)
- func ReadJsonMessageFromStream[T any](stream types.Stream) (*T, error)
- func ReadMessageFromStream[T any](stream types.Stream, options ...ReadOption) (*T, error)
- func SendUniversalEvent(ctx context.Context, connectionManager ConnectionManager, event *nostr.Event, ...) (map[string]*nostr.OKEnvelope, error)
- func SendUniversalEventSingle(ctx context.Context, connectionManager ConnectionManager, connectionID string, ...) (*nostr.OKEnvelope, error)
- func SetupConnection(useLibp2p bool, address string) (types.Connector, error)
- func UploadDag(ctx context.Context, connectionManager ConnectionManager, dag *merkle_dag.Dag, ...) error
- func UploadDagSingle(ctx context.Context, connectionManager ConnectionManager, connectionID string, ...) error
- func WaitForAdvancedQueryMessage(stream types.Stream) (*types.AdvancedQueryMessage, error)
- func WaitForDownloadMessage(stream types.Stream) (*types.DownloadMessage, error)
- func WaitForQueryMessage(stream types.Stream) (*types.QueryMessage, error)
- func WaitForResponse(stream types.Stream) (*types.ResponseMessage, error)
- func WaitForUploadMessage(stream types.Stream) (*types.UploadMessage, error)
- func WriteErrorToStream(stream types.Stream, message string, err error) error
- func WriteJsonMessageToStream[T any](stream types.Stream, message T) error
- func WriteMessageToStream[T any](stream types.Stream, message T, options ...WriteOption) error
- func WriteResponseToStream(stream types.Stream, response bool) error
- type ClaimOwnershipResult
- type ConnectionManager
- type GenericConnectionManager
- func (gcm *GenericConnectionManager) ConnectWithLibp2p(ctx context.Context, connectionId string, serverAddress string, ...) error
- func (gcm *GenericConnectionManager) ConnectWithWebsocket(ctx context.Context, connectionId string, url string) error
- func (gcm *GenericConnectionManager) Disconnect(connectionID string) error
- func (gcm *GenericConnectionManager) GetStream(ctx context.Context, connectionID string, protocolID string) (types.Stream, error)
- func (gcm *GenericConnectionManager) ListConnections() map[string]types.Connector
- type ReadOption
- type WriteOption
Constants ¶
View Source
const ( UploadID string = "/upload" DownloadID string = "/download" QueryID string = "/query" ClaimOwnershipID string = "/claim-ownership" )
Variables ¶
This section is empty.
Functions ¶
func BuildErrorMessage ¶
func BuildErrorMessage(message string, err error) types.ErrorMessage
func BuildResponseMessage ¶
func BuildResponseMessage(response bool, message ...string) types.ResponseMessage
func ClaimOwnership ¶
func ClaimOwnership(ctx context.Context, connectionManager ConnectionManager, connectionID string, root string, privateKey *secp256k1.PrivateKey) (*types.ResponseMessage, error)
ClaimOwnership claims ownership of an existing DAG root on a relay. The DAG must already exist on the relay. This is useful when a DAG was uploaded by another user and you want to claim ownership (e.g., for preventing garbage collection). The function signs the root hash with the provided private key to prove ownership.
func ClaimOwnershipAll ¶
func ClaimOwnershipAll(ctx context.Context, connectionManager ConnectionManager, root string, privateKey *secp256k1.PrivateKey) map[string]*ClaimOwnershipResult
ClaimOwnershipAll claims ownership of a DAG root on all connected relays. Returns a map of connection IDs to their responses or errors.
func DownloadDag ¶
func DownloadDag(ctx context.Context, connectionManager ConnectionManager, connectionID string, root string, privatekey *secp256k1.PrivateKey, filter *types.DownloadFilter, progressChan chan<- types.DownloadProgress) (context.Context, *types.DagData, error)
func QueryDag ¶
func QueryDag(ctx context.Context, connectionManager ConnectionManager, connectionID string, query types.QueryFilter) ([]string, error)
func QueryEvents ¶
func ReadEnvelopeFromStream ¶
func ReadMessageFromStream ¶
func ReadMessageFromStream[T any](stream types.Stream, options ...ReadOption) (*T, error)
func SendUniversalEvent ¶
func SendUniversalEvent(ctx context.Context, connectionManager ConnectionManager, event *nostr.Event, subscriptionId *string) (map[string]*nostr.OKEnvelope, error)
func SendUniversalEventSingle ¶
func SendUniversalEventSingle(ctx context.Context, connectionManager ConnectionManager, connectionID string, event *nostr.Event, subscriptionId *string) (*nostr.OKEnvelope, error)
func SetupConnection ¶
func UploadDag ¶
func UploadDag(ctx context.Context, connectionManager ConnectionManager, dag *merkle_dag.Dag, privatekey *secp256k1.PrivateKey, progressChan chan<- types.UploadProgress) error
func UploadDagSingle ¶
func UploadDagSingle(ctx context.Context, connectionManager ConnectionManager, connectionID string, dag *merkle_dag.Dag, privatekey *secp256k1.PrivateKey, progressChan chan<- types.UploadProgress) error
func WaitForAdvancedQueryMessage ¶
func WaitForAdvancedQueryMessage(stream types.Stream) (*types.AdvancedQueryMessage, error)
func WaitForDownloadMessage ¶
func WaitForDownloadMessage(stream types.Stream) (*types.DownloadMessage, error)
func WaitForQueryMessage ¶
func WaitForQueryMessage(stream types.Stream) (*types.QueryMessage, error)
func WaitForResponse ¶
func WaitForResponse(stream types.Stream) (*types.ResponseMessage, error)
func WaitForUploadMessage ¶
func WaitForUploadMessage(stream types.Stream) (*types.UploadMessage, error)
func WriteErrorToStream ¶
func WriteMessageToStream ¶
func WriteMessageToStream[T any](stream types.Stream, message T, options ...WriteOption) error
Types ¶
type ClaimOwnershipResult ¶
type ClaimOwnershipResult struct {
Response *types.ResponseMessage
Error error
}
ClaimOwnershipResult holds the result of a claim ownership operation for a single connection.
type ConnectionManager ¶
type ConnectionManager interface {
ConnectWithLibp2p(ctx context.Context, connectionId string, serverAddress string, opts ...libp2p.Option) error
ConnectWithWebsocket(ctx context.Context, connectionId string, url string) error
Disconnect(connectionID string) error
GetStream(ctx context.Context, connectionID string, protocolID string) (types.Stream, error)
ListConnections() map[string]types.Connector
}
type GenericConnectionManager ¶
type GenericConnectionManager struct {
// contains filtered or unexported fields
}
func NewGenericConnectionManager ¶
func NewGenericConnectionManager() *GenericConnectionManager
func (*GenericConnectionManager) ConnectWithLibp2p ¶
func (*GenericConnectionManager) ConnectWithWebsocket ¶
func (*GenericConnectionManager) Disconnect ¶
func (gcm *GenericConnectionManager) Disconnect(connectionID string) error
func (*GenericConnectionManager) ListConnections ¶
func (gcm *GenericConnectionManager) ListConnections() map[string]types.Connector
type ReadOption ¶
type ReadOption func(*readOptions)
func WithRetries ¶
func WithRetries(maxRetries int) ReadOption
func WithRetryDelay ¶
func WithRetryDelay(delay time.Duration) ReadOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ReadOption
type WriteOption ¶
type WriteOption func(*writeOptions)
func WithWriteRetries ¶
func WithWriteRetries(maxRetries int) WriteOption
func WithWriteRetryDelay ¶
func WithWriteRetryDelay(delay time.Duration) WriteOption
func WithWriteTimeout ¶
func WithWriteTimeout(timeout time.Duration) WriteOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.