util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0, MIT Imports: 43 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ERR_INVALID_TOKEN           = "ERR_INVALID_TOKEN"
	ERR_TOKEN_EXPIRED           = "ERR_TOKEN_EXPIRED"
	ERR_AUTH_MISSING            = "ERR_AUTH_MISSING"
	ERR_WRONG_AUTH_FORMAT       = "ERR_WRONG_AUTH_FORMAT"
	ERR_INVALID_AUTH            = "ERR_INVALID_AUTH"
	ERR_AUTH_MISSING_BEARER     = "ERR_AUTH_MISSING_BEARER"
	ERR_NOT_AUTHORIZED          = "ERR_NOT_AUTHORIZED"
	ERR_MINER_NOT_OWNED         = "ERR_MINER_NOT_OWNED"
	ERR_INVALID_INVITE          = "ERR_INVALID_INVITE"
	ERR_USERNAME_TAKEN          = "ERR_USERNAME_TAKEN"
	ERR_USER_CREATION_FAILED    = "ERR_USER_CREATION_FAILED"
	ERR_USER_NOT_FOUND          = "ERR_USER_NOT_FOUND"
	ERR_INVALID_PASSWORD        = "ERR_INVALID_PASSWORD"
	ERR_INVITE_ALREADY_USED     = "ERR_INVITE_ALREADY_USED"
	ERR_CONTENT_ADDING_DISABLED = "ERR_CONTENT_ADDING_DISABLED"
	ERR_INVALID_INPUT           = "ERR_INVALID_INPUT"
	ERR_CONTENT_SIZE_OVER_LIMIT = "ERR_CONTENT_SIZE_OVER_LIMIT"
)
View Source
const (
	PermLevelUpload = 1
	PermLevelUser   = 2
	PermLevelAdmin  = 10
)
View Source
const DefaultContentSizeLimit = 34_000_000_000

Variables

View Source
var DefaultHashFunction = uint64(mh.SHA2_256)

Functions

func AppVersionMiddleware

func AppVersionMiddleware(appVersion string) echo.MiddlewareFunc

func CalculateCarSize

func CalculateCarSize(data cid.Cid, objects []Object) (uint64, error)

func CidIsUnwalkable

func CidIsUnwalkable(c cid.Cid) bool

func DirsFromPath

func DirsFromPath(collectionPath string, filename string) ([]string, error)

DirsFromPath splits a path into a list of directories

func EnsurePathIsLinked

func EnsurePathIsLinked(dirs []string, rootNode *merkledag.ProtoNode, ds format.DAGService) (*merkledag.ProtoNode, error)

func ErrorHandler

func ErrorHandler(err error, ctx echo.Context)

func ExtractAuth

func ExtractAuth(c echo.Context) (string, error)
func FilterUnwalkableLinks(links []*ipld.Link) []*ipld.Link

func ImportFile

func ImportFile(dserv ipld.DAGService, fi io.Reader) (ipld.Node, error)

func ParseDealLabel

func ParseDealLabel(s string) (cid.Cid, error)

func SetupDatabase

func SetupDatabase(dbval string) (*gorm.DB, error)

func TransferTerminated

func TransferTerminated(st *filclient.ChannelState) bool

func TryExtractFSNode

func TryExtractFSNode(nd ipld.Node) (*unixfs.FSNode, error)

func ValidatePeerInfo

func ValidatePeerInfo(peerID string, addresses []string) (*peer.AddrInfo, error)

Types

type AutoretrieveInitResponse

type AutoretrieveInitResponse struct {
	Handle         string         `json:"handle"`
	Token          string         `json:"token"`
	LastConnection time.Time      `json:"lastConnection"`
	AddrInfo       *peer.AddrInfo `json:"addrInfo"`
}

type AutoretrieveListResponse

type AutoretrieveListResponse struct {
	Handle         string         `json:"handle"`
	LastConnection time.Time      `json:"lastConnection"`
	AddrInfo       *peer.AddrInfo `json:"addrInfo"`
}

type ChanTrack

type ChanTrack struct {
	Dbid uint
	Last *filclient.ChannelState
}

type ContentAddIpfsBody

type ContentAddIpfsBody struct {
	ContentInCollection

	Root     string   `json:"root"`
	Filename string   `json:"filename"`
	Peers    []string `json:"peers"`
}

type ContentAddResponse

type ContentAddResponse struct {
	Cid       string   `json:"cid"`
	EstuaryId uint     `json:"estuaryId"`
	Providers []string `json:"providers"`
}

type ContentCreateBody

type ContentCreateBody struct {
	ContentInCollection

	Root     string      `json:"root"`
	Name     string      `json:"name"`
	Location string      `json:"location"`
	Type     ContentType `json:"type"`
}

type ContentCreateResponse

type ContentCreateResponse struct {
	ID uint `json:"id"`
}

type ContentInCollection

type ContentInCollection struct {
	CollectionID   string `json:"coluuid"`
	CollectionPath string `json:"colpath"`
}

type ContentType

type ContentType int64
const (
	Unknown ContentType = iota
	File
	Directory
)

func FindCIDType

func FindCIDType(ctx context.Context, root cid.Cid, dserv ipld.NodeGetter) (contentType ContentType)

FindCIDType checks if a pinned CID (root) is a file, a dir or unknown Returns dbmgr.File or dbmgr.Directory on success Returns dbmgr.Unknown otherwise

type DbAddr

type DbAddr struct {
	Addr address.Address
}

func (*DbAddr) Scan

func (dba *DbAddr) Scan(v interface{}) error

func (DbAddr) Value

func (dba DbAddr) Value() (driver.Value, error)

type DbCID

type DbCID struct {
	CID cid.Cid
}

func (DbCID) MarshalJSON

func (dbc DbCID) MarshalJSON() ([]byte, error)

func (*DbCID) Scan

func (dbc *DbCID) Scan(v interface{}) error

func (*DbCID) UnmarshalJSON

func (dbc *DbCID) UnmarshalJSON(b []byte) error

func (DbCID) Value

func (dbc DbCID) Value() (driver.Value, error)

type HeartbeatAutoretrieveResponse

type HeartbeatAutoretrieveResponse struct {
	Handle         string         `json:"handle"`
	LastConnection time.Time      `json:"lastConnection"`
	AddrInfo       *peer.AddrInfo `json:"addrInfo"`
}

type HttpError

type HttpError struct {
	Code    int
	Message string
	Details string
}

func (HttpError) Error

func (he HttpError) Error() string

type InitShuttleResponse

type InitShuttleResponse struct {
	Handle string `json:"handle"`
	Token  string `json:"token"`
}

type Object

type Object struct {
	Cid  cid.Cid
	Size uint64
}

type RetrievalFailureRecord

type RetrievalFailureRecord struct {
	gorm.Model
	Miner   string `json:"miner"`
	Phase   string `json:"phase"`
	Message string `json:"message"`
	Content uint   `json:"content"`
	Cid     DbCID  `json:"cid"`
}

type RetrievalProgress

type RetrievalProgress struct {
	Wait   chan struct{}
	EndErr error
}

type Shuttle

type Shuttle struct {
	Node       *node.Node
	Api        api.Gateway
	DB         *gorm.DB
	PinMgr     *pinner.PinManager
	Filc       *filclient.FilClient
	StagingMgr *stagingbs.StagingBSMgr

	GwayHandler *gateway.GatewayHandler

	Tracer trace.Tracer

	TcLk             sync.Mutex
	TrackingChannels map[string]*ChanTrack

	SplitLk          sync.Mutex
	SplitsInProgress map[uint]bool

	AddPinLk sync.Mutex

	Outgoing chan *drpc.Message

	Private            bool
	DisableLocalAdding bool
	Dev                bool

	Hostname      string
	EstuaryHost   string
	ShuttleHandle string
	ShuttleToken  string

	CommpMemo *memo.Memoizer

	AuthCache *lru.TwoQueueCache

	RetrLk               sync.Mutex
	RetrievalsInProgress map[uint]*RetrievalProgress

	InflightCids   map[cid.Cid]uint
	InflightCidsLk sync.Mutex
}

type ShuttleCreateContentBody

type ShuttleCreateContentBody struct {
	Root         cid.Cid  `json:"root"`
	Name         string   `json:"name"`
	Collections  []string `json:"collections"`
	Location     string   `json:"location"`
	DagSplitRoot uint     `json:"dagSplitRoot"`
	User         uint     `json:"user"`
}

type ShuttleListResponse

type ShuttleListResponse struct {
	Handle         string          `json:"handle"`
	Token          string          `json:"token"`
	Online         bool            `json:"online"`
	LastConnection time.Time       `json:"lastConnection"`
	AddrInfo       *peer.AddrInfo  `json:"addrInfo"`
	Address        address.Address `json:"address"`
	Hostname       string          `json:"hostname"`

	StorageStats *ShuttleStorageStats `json:"storageStats"`
}

type ShuttleStorageStats

type ShuttleStorageStats struct {
	BlockstoreSize uint64 `json:"blockstoreSize"`
	BlockstoreFree uint64 `json:"blockstoreFree"`
	PinCount       int64  `json:"pinCount"`
	PinQueueLength int64  `json:"pinQueueLength"`
}

type UserSettings

type UserSettings struct {
	Replication  int  `json:"replication"`
	Verified     bool `json:"verified"`
	DealDuration int  `json:"dealDuration"`

	MaxStagingWait       time.Duration `json:"maxStagingWait"`
	FileStagingThreshold int64         `json:"fileStagingThreshold"`

	ContentAddingDisabled bool `json:"contentAddingDisabled"`
	DealMakingDisabled    bool `json:"dealMakingDisabled"`

	UploadEndpoints []string `json:"uploadEndpoints"`
	Flags           int      `json:"flags"`
}

type ViewerResponse

type ViewerResponse struct {
	Username string   `json:"username"`
	Perms    int      `json:"perms"`
	ID       uint     `json:"id"`
	Address  string   `json:"address,omitempty"`
	Miners   []string `json:"miners,omitempty"`

	AuthExpiry time.Time

	Settings UserSettings `json:"settings"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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