domain

package
v0.0.0-...-92c45cb Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Copy and pasted from `comiccoin`

Index

Constants

View Source
const (
	StatusQueued  = "queued"
	StatusPinning = "pinning"
	StatusPinned  = "pinned"
	StatusFailed  = "failed"

	ContentTypeFile  = 1
	ContentTypeImage = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IPFSRepository

type IPFSRepository interface {
	ID() (peer.ID, error)
	AddViaFilePath(fullFilePath string, shouldPin bool) (string, error)
	AddViaFileContent(fileContent []byte, shouldPin bool) (string, error)
	AddViaFile(file *os.File, shouldPin bool) (string, error)
	AddViaReaderFile(node files.File, shouldPin bool) (string, error)
	Pin(cidString string) error
	PinAddViaFilePath(fullFilePath string) (string, error)
	Get(ctx context.Context, cidString string) ([]byte, string, error)
}

type PinObject

type PinObject struct {
	// RequestID variable is the public viewable unique identifier of this pin.
	RequestID uint64 `json:"requestid"`

	// Status represents operational state of this pinned object in IPFS.
	Status string `json:"status"`

	// CID variable is the unique identifier of our content on the IPFS network. The official definition is: Content Identifier (CID) points at the root of a DAG that is pinned recursively.
	CID string `json:"cid"`

	// Name variable used to provide human readable description for the content. This is optional.
	Name string `json:"name"`

	// The date/time this content was pinned in IPFS network. Developers note: Normally we write it as `CreatedAt`, but IPFS specs require us to write it this way.
	Created time.Time `json:"created,omitempty"`

	// Addresses provided in origins list are relevant only during the initial pinning, and don't need to be persisted by the pinning service
	Origins []string `json:"origins"`

	// Any additional vendor-specific information is returned in optional info.
	Meta map[string]string `json:"meta"`

	// Addresses in the delegates array are peers designated by pinning service that will receive the pin data over bitswap
	Delegates []string `json:"delegates"`

	// Any additional vendor-specific information is returned in optional info.
	Info map[string]string `json:"info"`

	// FileContent variable holds all the content of this pin. Variable will not be saved to database, only returned in API endpoint.
	Content []byte `json:"content,omitempty"`

	Filename    string `json:"filename,omitempty"`
	ContentType int8   `json:"content_type,omitempty"`

	// ID variable is the unique identifier we use internally in our system.
	CreatedFromIPAddress  string    `json:"created_from_ip_address,omitempty"`
	ModifiedAt            time.Time `json:"modified_at,omitempty"`
	ModifiedFromIPAddress string    `json:"modified_from_ip_address,omitempty"`
}

PinObject is a representation of a pin request. It means it is the IPFS content which we are saving in our system and sharing to the IPFS network, also know as "pinning". This structure has the core variables required to work with IPFS as per their documentation https://ipfs.github.io/pinning-services-api-spec/#section/Schemas/Identifiers, in additon we also have our applications specific varaibles.

func NewPinObjectFromDeserialize

func NewPinObjectFromDeserialize(data []byte) (*PinObject, error)

NewPinObjectFromDeserialize deserializes a pin object from a byte array. It returns the deserialized block data DTO and an error if one occurs.

func (*PinObject) Serialize

func (b *PinObject) Serialize() ([]byte, error)

Serialize serializes a pin object into a byte array. It returns the serialized byte array and an error if one occurs.

type PinObjectAsSelectOption

type PinObjectAsSelectOption struct {
	Value uint64 `json:"value"` // Extract from the database `_id` field and output through API as `value`.
	Label string `json:"label"`
}

type PinObjectRepository

type PinObjectRepository interface {
	Upsert(pinobj *PinObject) error
	// GetByID(ctx context.Context, id uint64) (*PinObject, error)
	GetByCID(cid string) (*PinObject, error)
	GetByRequestID(requestID uint64) (*PinObject, error)
	ListAll() ([]*PinObject, error)
	DeleteByCID(cid string) error
	DeleteByRequestID(requestID uint64) error
	OpenTransaction() error
	CommitTransaction() error
	DiscardTransaction()
}

PinObjectRepository Interface for pinobject.

Jump to

Keyboard shortcuts

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