pod

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 31 Imported by: 3

Documentation

Index

Constants

View Source
const (
	GroupFile = "Groups"
)
View Source
const (

	// PasswordLength defines the pod password length
	PasswordLength = 32
)

Variables

View Source
var (
	// ErrBlankPodName is returned when a pod name is empty.
	ErrBlankPodName = errors.New("pod name cannot be blank")
	// ErrInvalidPodName is returned when a pod name is invalid.
	ErrInvalidPodName = errors.New("pod does not exist")
	// ErrTooLongPodName is returned when a pod name is too long.
	ErrTooLongPodName = errors.New("pod name too long")
	// ErrPodAlreadyExists is returned when a pod already exists.
	ErrPodAlreadyExists = errors.New("pod already exists")
	// ErrForkAlreadyExists is returned when a pod fork already exists.
	ErrForkAlreadyExists = errors.New("pod with fork name already exists")
	// ErrMaxPodsReached is returned when the maximum number of pods is reached.
	ErrMaxPodsReached = errors.New("max number of pods reached")
	// ErrPodNotOpened is returned when a pod is not opened.
	ErrPodNotOpened = errors.New("pod not opened")
	// ErrInvalidDirectory is returned when a directory is invalid.
	ErrInvalidDirectory = errors.New("invalid directory name")
	// ErrTooLongDirectoryName is returned when a directory name is too long.
	ErrTooLongDirectoryName = errors.New("directory name too long")
	// ErrInvalidFile is returned when a file is invalid.
	ErrInvalidFile = errors.New("file does not exist")
	// ErrMaximumPodLimit is returned when the maximum number of pods is reached.
	ErrMaximumPodLimit = errors.New("maximum number of pods has reached")
	// ErrBlankPodSharingReference is returned when a pod sharing reference is blank.
	ErrBlankPodSharingReference = errors.New("pod sharing reference cannot be blank")
)
View Source
var (
	// ErrGroupAlreadyExists is returned when a group already exists
	ErrGroupAlreadyExists = fmt.Errorf("group already exists")

	// ErrGroupDoesNotExist is returned when a group does not exist
	ErrGroupDoesNotExist = fmt.Errorf("group does not exist")

	ErrPermissionDenied = fmt.Errorf("permission denied")
)

Functions

func CleanPodName

func CleanPodName(podName string) (string, error)

CleanPodName trims spaces from a pod name

Types

type Group added in v0.10.0

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

Group is the main struct which acts on groups

func NewGroup added in v0.10.0

func NewGroup(client blockstore.Client, feed *feed.API, account *account.Account, acl acl.ACL, logger logging.Logger) *Group

NewGroup creates the main group object which has all the methods related to the groups.

func (*Group) AcceptGroupInvite added in v0.10.0

func (g *Group) AcceptGroupInvite(ref []byte) error

func (*Group) AddMember added in v0.10.0

func (g *Group) AddMember(groupName string, memberAddress common.Address, memberPublicKey *ecdsa.PublicKey, permission uint8) ([]byte, error)

func (*Group) CloseGroup added in v0.10.0

func (g *Group) CloseGroup(podName string) error

CloseGroup closed an already opened group and removes its information from directory and file data structures.

func (*Group) CreateGroup added in v0.10.0

func (g *Group) CreateGroup(name string) (*Info, error)

CreateGroup creates a new Group

func (*Group) GetGroupInfoFromMap added in v0.10.0

func (g *Group) GetGroupInfoFromMap(name string) (*Info, string, error)

GetGroupInfoFromMap returns the group info for the given group name.

func (*Group) GetGroupMembers added in v0.10.0

func (g *Group) GetGroupMembers(groupName string) (map[string]uint8, error)

func (*Group) GetPermission added in v0.10.0

func (g *Group) GetPermission(groupName string) (uint8, error)

func (*Group) ListGroup added in v0.10.0

func (g *Group) ListGroup() (*GroupList, error)

func (*Group) OpenGroup added in v0.10.0

func (g *Group) OpenGroup(name string) (*Info, error)

OpenGroup opens a new Group

func (*Group) RemoveGroup added in v0.10.0

func (g *Group) RemoveGroup(groupName string) error

RemoveGroup removes a group

func (*Group) RemoveMember added in v0.10.0

func (g *Group) RemoveMember(groupName string, memberAddress common.Address) error

func (*Group) RemoveSharedGroup added in v0.10.0

func (g *Group) RemoveSharedGroup(groupName string) error

RemoveSharedGroup removes a group from sharedGroup list

func (*Group) UpdatePermission added in v0.10.0

func (g *Group) UpdatePermission(groupName string, memberAddress common.Address, permission uint8) error

type GroupItem added in v0.10.0

type GroupItem struct {
	Name           string `json:"name"`
	OwnerPublicKey []byte `json:"ownerPublicKey"`
	OwnerAddress   string `json:"ownerAddress"`
	Password       string `json:"password"`
	Secret         []byte `json:"secret"`
}

GroupItem defines the structure for a group

type GroupList added in v0.10.0

type GroupList struct {
	Groups       []GroupItem `json:"groups"`
	SharedGroups []GroupItem `json:"sharedGroups"`
}

GroupList lists all the groups

type Info

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

Info is the struct which holds the pod information

func (*Info) GetAccountInfo

func (i *Info) GetAccountInfo() *account.Info

GetAccountInfo returns the pod account info

func (*Info) GetDirectory

func (i *Info) GetDirectory() *di.Directory

GetDirectory returns the directory object

func (*Info) GetDocStore

func (i *Info) GetDocStore() *collection.Document

GetDocStore returns docStore skipcq: TCV-001

func (*Info) GetFeed

func (i *Info) GetFeed() *feed.API

GetFeed returns the feed object

func (*Info) GetFile added in v0.5.3

func (i *Info) GetFile() *f.File

GetFile returns the file object

func (*Info) GetKVStore

func (i *Info) GetKVStore() *collection.KeyValue

GetKVStore returns kvStore skipcq: TCV-001

func (*Info) GetPodAddress added in v0.5.3

func (i *Info) GetPodAddress() utils.Address

GetPodAddress returns the pod address

func (*Info) GetPodName added in v0.5.3

func (i *Info) GetPodName() string

GetPodName returns the pod name

func (*Info) GetPodPassword added in v0.9.1

func (i *Info) GetPodPassword() string

GetPodPassword returns the pod password

type List added in v0.9.2

type List struct {
	Pods       []ListItem       `json:"pods"`
	SharedPods []SharedListItem `json:"sharedPods"`
}

List lists all the pods

type ListItem added in v0.9.2

type ListItem struct {
	Name     string `json:"name"`
	Index    int    `json:"index"`
	Password string `json:"password"`
}

ListItem defines the structure for pod item

type Pod

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

Pod is the main struct which acts on pods

func NewPod

func NewPod(client blockstore.Client, feed *feed.API, account *account.Account, m taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, feedCacheSize int, feedCacheTTL time.Duration, logger logging.Logger) *Pod

NewPod creates the main pod object which has all the methods related to the pods.

func (*Pod) ApproveSubscription added in v0.9.3

func (p *Pod) ApproveSubscription(podName string, requestHash [32]byte, subscriberPublicKey *ecdsa.PublicKey) error

ApproveSubscription will send a subscriptionManager request to the owner of the pod

func (*Pod) CloseAllPods added in v0.10.0

func (p *Pod) CloseAllPods() error

CloseAllPods closes all opened pods and removes their information from directory and file data structures.

func (*Pod) ClosePod

func (p *Pod) ClosePod(podName string) error

ClosePod closed an already opened pod and removes its information from directory and file data structures.

func (*Pod) CommitFeeds added in v0.10.0

func (p *Pod) CommitFeeds(podName string) error

CommitFeeds commits uncommitted feeds saved in local lru cache to swarm

func (*Pod) CreatePod

func (p *Pod) CreatePod(podName, addressString, podPassword string) (*Info, error)

CreatePod creates a new pod for a given user.

func (*Pod) DeleteOwnPod added in v0.7.0

func (p *Pod) DeleteOwnPod(podName string) error

DeleteOwnPod removed a pod and the list of pods belonging to a user.

func (*Pod) DeleteSharedPod added in v0.7.0

func (p *Pod) DeleteSharedPod(podName string) error

DeleteSharedPod removed a pod and the list of pods shared by other users.

func (*Pod) EncryptUploadSubscriptionInfo added in v0.9.3

func (p *Pod) EncryptUploadSubscriptionInfo(podName string, subscriberPublicKey *ecdsa.PublicKey) (string, error)

EncryptUploadSubscriptionInfo will upload sub pod info into swarm

func (*Pod) GetAccount added in v0.5.3

func (p *Pod) GetAccount() *account.Account

GetAccount returns the account object

func (*Pod) GetAccountInfo

func (p *Pod) GetAccountInfo(podName string) (*account.Info, error)

GetAccountInfo returns the pod account info

func (*Pod) GetFeed added in v0.5.3

func (p *Pod) GetFeed() *feed.API

GetFeed returns the feed object

func (*Pod) GetMarketplace added in v0.9.3

func (p *Pod) GetMarketplace() ([]datahub.DataHubSub, error)

GetMarketplace will query the smart contract make the `list` all the pod from the marketplace

func (*Pod) GetName

func (*Pod) GetName(inode *d.Inode) string

GetName returns the name of the node in a pod

func (*Pod) GetPath

func (*Pod) GetPath(inode *d.Inode) string

GetPath returns the path of the node in a pod

func (*Pod) GetPodInfo added in v0.9.3

func (p *Pod) GetPodInfo(podName string) (*Info, string, error)

GetPodInfo returns the pod info for the given pod name.

func (*Pod) GetPodInfoFromPodMap

func (p *Pod) GetPodInfoFromPodMap(podName string) (*Info, string, error)

GetPodInfoFromPodMap returns the pod info for the given pod name.

func (*Pod) GetPodSharingInfo added in v0.9.3

func (p *Pod) GetPodSharingInfo(podName string) (*ShareInfo, error)

GetPodSharingInfo returns the raw shareInfo

func (*Pod) GetSubRequests added in v0.9.3

func (p *Pod) GetSubRequests() ([]datahub.DataHubSubRequest, error)

GetSubRequests will get all owners sub requests

func (*Pod) GetSubscribablePodInfo added in v0.9.3

func (p *Pod) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error)

GetSubscribablePodInfo will query the smart contract and get info by subHash

func (*Pod) GetSubscriptions added in v0.9.3

func (p *Pod) GetSubscriptions(nameHash [32]byte) ([]datahub.DataHubSubItem, error)

GetSubscriptions will query the smart contract and list my subscriptions

func (*Pod) IsOwnPodPresent added in v0.9.3

func (p *Pod) IsOwnPodPresent(podName string) bool

IsOwnPodPresent checks if a pod is already present for user

func (*Pod) IsPodPresent added in v0.7.3

func (p *Pod) IsPodPresent(podName string) bool

IsPodPresent checks if a pod is already present for user

func (*Pod) ListPodInMarketplace added in v0.9.3

func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price uint64, daysValid uint16, category, nameHash [32]byte) error

ListPodInMarketplace will save the pod info in the subscriptionManager smart contract with its owner and price we keep the pod info in the smart contract, with a `list` flag

func (*Pod) ListPods

func (p *Pod) ListPods() ([]string, []string, error)

ListPods List all the available pods belonging to a user.

func (*Pod) OpenFromShareInfo added in v0.9.3

func (p *Pod) OpenFromShareInfo(si *ShareInfo) (*Info, error)

func (*Pod) OpenPod

func (p *Pod) OpenPod(podName string) (*Info, error)

OpenPod opens a pod if it is not already opened. as part of opening the pod it loads all the data structures related to the pod. Also, it syncs all the files and directories under this pod from the Swarm network.

func (*Pod) OpenPodAsync added in v0.9.1

func (p *Pod) OpenPodAsync(ctx context.Context, podName string) (*Info, error)

OpenPodAsync opens a pod if it is not already opened. as part of opening the pod it loads all the data structures related to the pod. Also, it syncs all the files and directories under this pod from the Swarm network.

func (*Pod) OpenSubscribedPod added in v0.9.3

func (p *Pod) OpenSubscribedPod(reference []byte, ownerPublicKey *ecdsa.PublicKey) (*Info, error)

OpenSubscribedPod will open a subscribed pod

func (*Pod) OpenSubscribedPodFromReference added in v0.9.3

func (p *Pod) OpenSubscribedPodFromReference(reference string, ownerPublicKey *ecdsa.PublicKey) (*Info, error)

OpenSubscribedPodFromReference will open a subscribed pod

func (*Pod) PodFork added in v0.9.2

func (p *Pod) PodFork(podName, forkName string) error

PodFork forks a pod with a different given name

func (*Pod) PodForkFromRef added in v0.9.2

func (p *Pod) PodForkFromRef(forkName, refString string) error

PodForkFromRef forks a pof from a given pod sharing reference

func (*Pod) PodList added in v0.9.1

func (p *Pod) PodList() (*List, error)

PodList lists all the available pods belonging to a user in json format.

func (*Pod) PodShare

func (p *Pod) PodShare(podName, sharedPodName string) (string, error)

PodShare makes a pod public by exporting all the pod related information and its address. it does this by creating a sharing reference which points to the information required to import this pod.

func (*Pod) PodStat

func (p *Pod) PodStat(podName string) (*Stat, error)

PodStat shows all the pod related information like podname and its current address.

func (*Pod) PodStatusInMarketplace added in v0.9.3

func (p *Pod) PodStatusInMarketplace(subHash [32]byte, show bool) error

PodStatusInMarketplace will change the `list` flag for the pod so that it's not listed or gets re listed in the pod marketplace

func (*Pod) ReceivePod

func (p *Pod) ReceivePod(sharedPodName string, ref utils.Reference) (*Info, error)

ReceivePod imports a pod by creating a new pod with the same name and password

func (*Pod) ReceivePodInfo

func (p *Pod) ReceivePodInfo(ref utils.Reference) (*ShareInfo, error)

ReceivePodInfo returns the shareInfo from the reference

func (*Pod) RequestSubscription added in v0.9.3

func (p *Pod) RequestSubscription(subHash, nameHash [32]byte) error

RequestSubscription will send a subscriptionManager request to the owner of the pod will create an escrow account and deposit the `price`

func (*Pod) SyncPod

func (p *Pod) SyncPod(podName string) error

SyncPod syncs the pod to the latest version by extracting the current meta information of files and directories of the pod.

func (*Pod) SyncPodAsync added in v0.9.1

func (p *Pod) SyncPodAsync(ctx context.Context, podName string) error

SyncPodAsync syncs the pod to the latest version by extracting the current meta information of files and directories of the pod, concurrently.

type ShareInfo

type ShareInfo struct {
	PodName     string `json:"podName"`
	Address     string `json:"podAddress"`
	Password    string `json:"password"`
	UserAddress string `json:"userAddress"`
}

ShareInfo is the structure of the share info

type SharedListItem added in v0.9.2

type SharedListItem struct {
	Name     string `json:"name"`
	Address  string `json:"address"`
	Password string `json:"password"`
}

SharedListItem defines the structure for shared pod item

type Stat added in v0.9.1

type Stat struct {
	PodName    string `json:"podName"`
	PodAddress string `json:"address"`
}

Stat represents a pod name and address

Jump to

Keyboard shortcuts

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