Documentation
¶
Index ¶
- Constants
- func NewClient(ctx context.Context, cfg EnvConfig, extra ...synapse.ClientOption) (*synapse.Client, error)
- func NormalizeRPCURL(raw string) string
- func OpenFile(path string) (*os.File, error)
- func OpenRegularFile(path string) (*os.File, os.FileInfo, error)
- func ParseChain(raw string) (*chain.Chain, error)
- func PrintPrepare(w io.Writer, result *storage.PrepareResult) error
- func ValidateUploadSize(label string, size int64) error
- func WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- func WriteKV(w io.Writer, key string, value any) error
- func WriteMap(w io.Writer, prefix string, values map[string]string) error
- func WriteTx(w io.Writer, prefix string, result *types.WriteResult) error
- type EnvConfig
- type MetadataFlag
Constants ¶
const ( // DefaultRPCURL points at Filecoin Calibration, the network targeted by // these runnable examples. DefaultRPCURL = "https://api.calibration.node.glif.io/rpc/v1" DefaultTimeout = 30 * time.Minute MinUploadBytes = 127 PrivateKeyEnvVar = "SYNAPSE_PRIVATE_KEY" RPCURLEnvVar = "SYNAPSE_RPC_URL" ChainEnvVar = "SYNAPSE_CHAIN" )
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(ctx context.Context, cfg EnvConfig, extra ...synapse.ClientOption) (*synapse.Client, error)
NewClient creates a root SDK client from EnvConfig.
func NormalizeRPCURL ¶
NormalizeRPCURL accepts the GLIF host-only URLs that older examples used and converts them to the JSON-RPC endpoint expected by Filecoin clients.
func OpenRegularFile ¶
OpenRegularFile opens a regular file for upload examples.
func ParseChain ¶
ParseChain maps SYNAPSE_CHAIN to a known chain. Empty means auto-detect from RPC.
func PrintPrepare ¶
func PrintPrepare(w io.Writer, result *storage.PrepareResult) error
PrintPrepare writes the funding summary returned by storage.Prepare.
func ValidateUploadSize ¶
ValidateUploadSize rejects payloads too small to produce a PieceCIDv2.
func WithTimeout ¶
func WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
WithTimeout applies a consistent timeout to example commands.
Types ¶
type EnvConfig ¶
EnvConfig contains the common wallet/RPC settings shared by examples.
func LoadEnv ¶
LoadEnv reads the standard example environment. SYNAPSE_PRIVATE_KEY is required; SYNAPSE_RPC_URL defaults to the public Calibration endpoint.
func (EnvConfig) ClientOptions ¶
func (c EnvConfig) ClientOptions(extra ...synapse.ClientOption) []synapse.ClientOption
ClientOptions returns synapse.New options for the common environment.
type MetadataFlag ¶
MetadataFlag parses repeated key=value flags into a map.
func (MetadataFlag) Map ¶
func (m MetadataFlag) Map() map[string]string
Map returns a copy suitable for SDK option structs. Empty maps become nil.
func (*MetadataFlag) Set ¶
func (m *MetadataFlag) Set(raw string) error
func (*MetadataFlag) String ¶
func (m *MetadataFlag) String() string