Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket interface { // Get opens a file stream Get(ctx context.Context, filename string) (Fetcher, error) // Put writes a file to the storage Put(ctx context.Context, filename string, file io.Reader, mtime time.Time) error // PutAndLock writes a file to the storage and locks it PutAndLock(ctx context.Context, filename string, file io.Reader, mtime time.Time) (*pb.LockToken, error) // PutWithCacheTTL writes a file and set the cache update interval. // This will cache the content in the nodes, no updates will be retrieved // from the network until the ttl is timed out // ttl is in seconds. PutWithCacheTTL(ctx context.Context, filename string, file io.Reader, mtime time.Time, ttl uint64) error // Remove deletes a file from the storage Remove(ctx context.Context, filename string) error // Lock locks a file to avoid replublishing and overwritting during sequential updates from a single writer Lock(ctx context.Context, filename string) (*pb.LockToken, error) // IsLocked check if a file is locked IsLocked(ctx context.Context, filename string) (bool, error) // Unlock unlocks a file. See Lock Unlock(ctx context.Context, filename string, token *pb.LockToken) error Chroot(dir string) Bucket }
Bucket bucket managemente interface
type Core ¶
type Core interface { // Get opens a file stream Get(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string) (Fetcher, error) // Put writes a file to the storage Put(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string, file io.Reader, mtime time.Time) error // PutAndLock writes a file to the storage and locks it PutAndLock(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string, file io.Reader, mtime time.Time) (*pb.LockToken, error) // PutWithCacheTTL writes a file and set the cache update interval. // This will cache the content in the nodes, no updates will be retrieved // from the network until the ttl is timed out // ttl is in seconds. PutWithCacheTTL(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string, file io.Reader, mtime time.Time, ttl uint64) error // Remove deletes a file from the storage Remove(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string) error // Lock locks a file to avoid replublishing and overwritting during sequential updates from a single writer Lock(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string) (*pb.LockToken, error) // Unlock unlocks a file. See Lock Unlock(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string, token *pb.LockToken) error // IsLocked check if a file is locked IsLocked(ctx context.Context, publicKey crabfsCrypto.PubKey, bucket string, filename string) (bool, error) // GetID returns the network id of this node GetID() string // GetAddrs returns the addresses bound to this node GetAddrs() []string // Blockstore returns the currently used blockstore Blockstore() ipfsBlockstore.Blockstore // Host returns the currently used host Host() Host // GarbageCollector returns the garbage collector associated with this instance GarbageCollector() GarbageCollector // Close closes this instance and stop all children goroutines Close() error // WithBucket wraps calls to a single bucket WithBucket(privateKey crabfsCrypto.PrivKey, bucket string) (Bucket, error) // WithBucketRoot wraps calls to a single bucket and base directory WithBucketRoot(privateKey crabfsCrypto.PrivKey, bucket string, baseDir string) (Bucket, error) // PublishPublicKey publishes a public key to the network PublishPublicKey(publicKey crabfsCrypto.PubKey) error // GetIdentity returns the current identity of the node GetIdentity() identity.Identity }
Core interface
type Fetcher ¶
type Fetcher interface { io.Reader io.Seeker io.Closer // Size returns the total size of the block map to fetch Size() int64 // Context returns the context of this fetcher // context is cancelled with the parent context or when Close is called Context() context.Context }
Fetcher block fetcher interface
type FetcherFactory ¶
type FetcherFactory func(ctx context.Context, fs Core, object *pb.CrabObject, privateKey crabfsCrypto.PrivKey) (Fetcher, error)
FetcherFactory fetcher factory type
type GarbageCollector ¶
type GarbageCollector interface { // Start starts this garbage collector Start() error // Schedule schedules a clean up as soon as possible Schedule() error // Collect perform a clean up now Collect() error // Locker returns the garbage collector locker Locker() sync.Locker }
GarbageCollector periodically runs a clean up in the blockstore to remove unused blocks
type Host ¶
type Host interface { // Close closes this host and all open connections Close() error // Announce Announce() error // GetSwarmPublicKey get the swarm public key from the keystore GetSwarmPublicKey(ctx context.Context, hash string) (crabfsCrypto.PubKey, error) // Publish publishes a block map Publish(ctx context.Context, privateKey crabfsCrypto.PrivKey, cipherKey []byte, bucket string, filename string, blockMap BlockMap, mtime time.Time, size int64) error // PublishAndLock publishes a locked block map PublishAndLock(ctx context.Context, privateKey crabfsCrypto.PrivKey, cipherKey []byte, bucket string, filename string, blockMap BlockMap, mtime time.Time, size int64) (*pb.LockToken, error) // PublishWithCacheTTL same as Publish but specifies a cache ttl timeout. // This will cache the content in the nodes, no updates will be retrieved // from the network until the ttl is timed out // ttl is in seconds. PublishWithCacheTTL(ctx context.Context, privateKey crabfsCrypto.PrivKey, cipherKey []byte, bucket string, filename string, blockMap BlockMap, mtime time.Time, size int64, ttl uint64) error // Remove removes content from the network Remove(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string) error // GetContent get the block map specified by 'filename GetContent(ctx context.Context, publicKey crabfsCrypto.PubKey, bucket string, filename string) (*pb.CrabObject, error) // Lock locks a file to avoid replublishing and overwritting during sequential updates from a single writer Lock(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string) (*pb.LockToken, error) // Unlock unlocks a file. See Lock Unlock(ctx context.Context, privateKey crabfsCrypto.PrivKey, bucket string, filename string, token *pb.LockToken) error // IsLocked check if a file is locked IsLocked(ctx context.Context, publicKey crabfsCrypto.PubKey, bucket string, filename string) (bool, error) // FindProviders find the closest providers of cid FindProviders(ctx context.Context, blockMeta *pb.BlockMetadata) <-chan libp2pPeerstore.PeerInfo // CreateBlockStream downloads a block 'cid' from peer CreateBlockStream(ctx context.Context, blockMeta *pb.BlockMetadata, peer *libp2pPeerstore.PeerInfo) (io.Reader, error) // GetID returns the network id of this host GetID() string // GetAddrs returns the addresses bound to this host GetAddrs() []string // Reprovide republish blocks and block metas to the network Reprovide(ctx context.Context, withBlocks bool) error // PutPublicKey broadcast this public key to the network PutPublicKey(publicKey crabfsCrypto.PubKey) error // Provide publishes a block in the network Provide(ctx context.Context, cid cid.Cid) error }
Host p2p host abstraction
Click to show internal directories.
Click to hide internal directories.