Documentation
¶
Index ¶
- Variables
- func CID(v any) (types.HexBytes, error)
- func CIDStringToHexBytes(s string) types.HexBytes
- func CIDToHexBytes(c cid.Cid) types.HexBytes
- func HexBytesToCID(b types.HexBytes) (cid.Cid, error)
- type LocalMetadata
- type MetadataKeyProvider
- type MetadataProvider
- type MetadataStorage
- type PinataMetadataProvider
- type PinataMetadataProviderConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when the metadata is not found ErrNotFound = fmt.Errorf("metadata not found") )
Functions ¶
func CID ¶
CID calculates the IPFS Cid hash (v1) from a bytes buffer, using parameters:
- Codec: DagProtobuf
- MhType: SHA2_256
func CIDStringToHexBytes ¶
CIDStringToHexBytes converts a string to a types.HexBytes cid
func CIDToHexBytes ¶
CIDToHexBytes converts a cid.Cid to a types.HexBytes
Types ¶
type LocalMetadata ¶
type LocalMetadata struct {
// contains filtered or unexported fields
}
LocalMetadata is a local implementation of the MetadataStorage interface that stores the metadata in an local database. It also provides a cache for the artifacts.
func NewLocalMetadata ¶
func NewLocalMetadata(db db.Database) *LocalMetadata
NewLocalMetadata creates a new LocalMetadata instance with the given database instance. It also creates a cache for the artifacts if possible and returns it.
func (*LocalMetadata) Metadata ¶
Metadata returns the metadata stored in the local database for the given key. It returns an error if the request fails.
func (*LocalMetadata) SetMetadata ¶
func (lm *LocalMetadata) SetMetadata(_ context.Context, key types.HexBytes, metadata *types.Metadata) error
SetMetadata stores the given metadata in the local database and returns an error if the request fails.
type MetadataKeyProvider ¶
MetadataKeyProvider is a function that returns the key for a given metadata
type MetadataProvider ¶
type MetadataProvider interface {
SetMetadata(ctx context.Context, key types.HexBytes, metadata *types.Metadata) error
Metadata(ctx context.Context, key types.HexBytes) (*types.Metadata, error)
}
MetadataProvider is an interface for storing and retrieving metadata
type MetadataStorage ¶
type MetadataStorage struct {
// contains filtered or unexported fields
}
MetadataStorage is a struct that stores and retrieves metadata for a given key. It wraps multiple metadata providers storing the metadata in all of them but retrieving it from the first one that has it.
func New ¶
func New(keyProvider MetadataKeyProvider, providers ...MetadataProvider) *MetadataStorage
New returns a new MetadataStorage for the given MetadataKeyProvider and MetadataProviders.
type PinataMetadataProvider ¶
type PinataMetadataProvider struct {
PinataMetadataProviderConfig
// contains filtered or unexported fields
}
PinataMetadataProvider is a provider for metadata stored in Pinata.
func NewPinataMetadataProvider ¶
func NewPinataMetadataProvider(config PinataMetadataProviderConfig) *PinataMetadataProvider
NewPinataMetadataProvider creates a new PinataMetadataProvider instance with the given configuration.
func (*PinataMetadataProvider) Metadata ¶
func (p *PinataMetadataProvider) Metadata(ctx context.Context, key types.HexBytes) (*types.Metadata, error)
Metadata returns the metadata stored in Pinata for the given key. It returns an error if the request fails.
func (*PinataMetadataProvider) SetMetadata ¶
func (p *PinataMetadataProvider) SetMetadata(ctx context.Context, key types.HexBytes, metadata *types.Metadata) error
SetMetadata stores the given metadata in Pinata. It returns an error if the request fails. It ensures that the resulting CID matches with the key provided.
type PinataMetadataProviderConfig ¶
type PinataMetadataProviderConfig struct {
HostnameURL string
HostnameJWT string
GatewayURL string
GatewayToken string
}
PinataMetadataProviderConfig is the configuration for the PinataMetadataProvider. It includes the hostname URL, JWT and gateway URL and token.
func (*PinataMetadataProviderConfig) Valid ¶
func (c *PinataMetadataProviderConfig) Valid() bool
Valid checks if the PinataMetadataProviderConfig is valid. It returns true if the hostname URL, JWT and gateway URL and token are not empty.