synapse

package
v0.0.0-...-0e07ff4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, cfg ClientConfig) (*sdk.Client, error)

NewClient creates a synapse-go Client from config fields.

Types

type AddPiecesStatusInput

type AddPiecesStatusInput struct {
	ServiceURL         string
	StatusURL          string
	DataSetID          string
	TransactionID      string
	ExpectedPieceCount int
}

type CleanupContext

type CleanupContext interface {
	DeletePieceByID(context.Context, sdktypes.BigInt) (*sdktypes.WriteResult, error)
	PieceStatus(context.Context, cid.Cid) (*storage.PieceStatus, error)
}

CleanupContext abstracts the SDK operations needed to remove PDP pieces.

type ClientConfig

type ClientConfig struct {
	PrivateKey           string
	RPCURL               string
	Source               string
	WithCDN              bool
	AllowPrivateNetworks bool
	Logger               *slog.Logger
}

ClientConfig contains SynapS3 runtime settings forwarded into synapse-go.

type DataSetCreationStatusInput

type DataSetCreationStatusInput struct {
	StatusURL         string
	TransactionID     string
	ExpectedDataSetID string
}

type PDPStatusChecker

type PDPStatusChecker struct {
	// contains filtered or unexported fields
}

func NewPDPStatusChecker

func NewPDPStatusChecker(opts PDPStatusCheckerOptions) *PDPStatusChecker

func (*PDPStatusChecker) CheckAddPiecesStatus

func (c *PDPStatusChecker) CheckAddPiecesStatus(ctx context.Context, input AddPiecesStatusInput) PDPStatusResult

func (*PDPStatusChecker) CheckDataSetCreationStatus

func (c *PDPStatusChecker) CheckDataSetCreationStatus(ctx context.Context, input DataSetCreationStatusInput) PDPStatusResult

type PDPStatusCheckerOptions

type PDPStatusCheckerOptions struct {
	Timeout              time.Duration
	AllowPrivateNetworks bool
}

type PDPStatusResult

type PDPStatusResult struct {
	State             PDPStatusState
	StatusURL         string
	TxStatus          string
	DataSetID         string
	DataSetCreated    bool
	PiecesAdded       bool
	PieceCount        int
	ConfirmedPieceIDs []string
	Error             string
}

type PDPStatusState

type PDPStatusState string
const (
	PDPStatusPending     PDPStatusState = "pending"
	PDPStatusConfirmed   PDPStatusState = "confirmed"
	PDPStatusRejected    PDPStatusState = "rejected"
	PDPStatusMismatch    PDPStatusState = "mismatch"
	PDPStatusUnavailable PDPStatusState = "unavailable"
	PDPStatusUnknown     PDPStatusState = "unknown"
)

type PaymentAccountInfo

type PaymentAccountInfo struct {
	Funds               *big.Int
	AvailableFunds      *big.Int
	LockupCurrent       *big.Int
	LockupRate          *big.Int
	LockupLastSettledAt *big.Int
	FundedUntilEpoch    *big.Int
	FundedUntilTime     *time.Time
	RunwaySeconds       *int64
	LockupRatePerDay    *big.Int
	LockupRatePerMonth  *big.Int
	NoActiveSpend       bool
}

PaymentAccountInfo holds USDFC payment contract account state.

type ReadinessCheck

type ReadinessCheck struct {
	ID      string          `json:"id"`
	Status  ReadinessStatus `json:"status"`
	Message string          `json:"message"`
	Action  string          `json:"action,omitempty"`
}

type ReadinessChecker

type ReadinessChecker struct {
	// contains filtered or unexported fields
}

func NewReadinessChecker

func NewReadinessChecker(cfg ReadinessConfig, runtime ReadinessClient, opts ...ReadinessCheckerOption) *ReadinessChecker

func (*ReadinessChecker) CheckDraft

func (*ReadinessChecker) CheckRuntime

func (c *ReadinessChecker) CheckRuntime(ctx context.Context) ReadinessResult

type ReadinessCheckerOption

type ReadinessCheckerOption func(*ReadinessChecker)

func WithReadinessClientFactory

func WithReadinessClientFactory(factory ReadinessClientFactory) ReadinessCheckerOption

func WithReadinessLogger

func WithReadinessLogger(logger *slog.Logger) ReadinessCheckerOption

func WithReadinessTimeout

func WithReadinessTimeout(timeout time.Duration) ReadinessCheckerOption

type ReadinessClient

type ReadinessClient interface {
	Address() common.Address
	Chain() chain.Chain
	Payments() readinessPayments
	Storage() readinessStorage
	Close() error
}

func AdaptReadinessClient

func AdaptReadinessClient(client *sdk.Client) ReadinessClient

type ReadinessClientFactory

type ReadinessClientFactory func(context.Context, ReadinessConfig) (ReadinessClient, error)

type ReadinessConfig

type ReadinessConfig struct {
	Network              string
	RPCURL               string
	PrivateKey           string
	Source               string
	WithCDN              bool
	AllowPrivateNetworks bool
	DefaultCopies        int
}

func ReadinessConfigFromFilecoinConfig

func ReadinessConfigFromFilecoinConfig(cfg config.FilecoinConfig) ReadinessConfig

type ReadinessMode

type ReadinessMode string
const (
	ReadinessModeRuntime ReadinessMode = "runtime"
	ReadinessModeDraft   ReadinessMode = "draft"
)

type ReadinessResult

type ReadinessResult struct {
	Status        ReadinessStatus   `json:"status"`
	Mode          ReadinessMode     `json:"mode"`
	CheckedAt     time.Time         `json:"checked_at"`
	Checks        []ReadinessCheck  `json:"checks"`
	PartialErrors map[string]string `json:"partial_errors,omitempty"`
}

func (*ReadinessResult) Finish

func (r *ReadinessResult) Finish()

Finish updates the aggregate readiness status from the contained checks.

type ReadinessStatus

type ReadinessStatus string
const (
	ReadinessStatusReady   ReadinessStatus = "ready"
	ReadinessStatusWarning ReadinessStatus = "warning"
	ReadinessStatusBlocked ReadinessStatus = "blocked"
	ReadinessStatusUnknown ReadinessStatus = "unknown"
)

type StorageClient

type StorageClient interface {
	Download(ctx context.Context, pieceCID cid.Cid, opts *storage.DownloadOptions) (io.ReadCloser, error)
	CreateContexts(ctx context.Context, opts *storage.CreateContextsOptions) ([]UploadContext, error)
	CreateContext(ctx context.Context, opts *storage.CreateContextOptions) (UploadContext, error)
	CreateCleanupContext(ctx context.Context, opts *storage.CreateContextOptions) (CleanupContext, error)
}

StorageClient abstracts the synapse-go storage service for download plus staged provider operations.

type StorageServiceAdapter

type StorageServiceAdapter struct {
	// contains filtered or unexported fields
}

StorageServiceAdapter adapts synapse-go's concrete storage service to SynapS3's testable staged storage interface. It exists because Go does not allow []*storage.Context to satisfy []UploadContext directly.

func AdaptStorageService

func AdaptStorageService(service *storage.Service) *StorageServiceAdapter

func (*StorageServiceAdapter) CreateCleanupContext

func (s *StorageServiceAdapter) CreateCleanupContext(ctx context.Context, opts *storage.CreateContextOptions) (CleanupContext, error)

func (*StorageServiceAdapter) CreateContext

func (*StorageServiceAdapter) CreateContexts

func (*StorageServiceAdapter) Download

func (s *StorageServiceAdapter) Download(ctx context.Context, pieceCID cid.Cid, opts *storage.DownloadOptions) (io.ReadCloser, error)

type UploadContext

UploadContext abstracts one provider-scoped SDK storage context.

type WalletInfo

type WalletInfo struct {
	Address              string
	Network              string
	ChainID              int64
	Nonce                *uint64
	CurrentEpoch         *big.Int
	EpochDurationSeconds int64
	PaymentsAddress      string
	USDFCAddress         string
	USDFCDecimals        uint8
	FILGasBalance        *big.Int
	USDFCWalletBalance   *big.Int
	PaymentAccount       *PaymentAccountInfo
	Errors               map[string]string
}

WalletInfo holds a snapshot of the wallet's on-chain state. Fields are nil when the corresponding RPC call failed; see Errors for details.

type WalletOperator

type WalletOperator interface {
	FundUSDFC(ctx context.Context, amount *big.Int) (string, error)
	WithdrawUSDFC(ctx context.Context, amount *big.Int) (string, error)
}

WalletOperator broadcasts wallet payment transactions.

func NewWalletOperator

func NewWalletOperator(paySvc *payments.Service, c chain.Chain) WalletOperator

type WalletQuerier

type WalletQuerier interface {
	GetWalletInfo(ctx context.Context) (*WalletInfo, error)
}

WalletQuerier provides on-chain wallet state for the admin dashboard.

func NewWalletQuerier

func NewWalletQuerier(paySvc *payments.Service, address common.Address, c chain.Chain) WalletQuerier

NewWalletQuerier creates a WalletQuerier backed by synapse-go payments.Service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL