ipnsfs

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

package ipnsfs implements an in memory model of a mutable ipns filesystem, to be used by the fuse filesystem.

It consists of four main structs:

  1. The Filesystem The filesystem serves as a container and entry point for the ipns filesystem
  2. KeyRoots KeyRoots represent the root of the keyspace controlled by a given keypair
  3. Directories
  4. Files

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidChild = errors.New("invalid child node")
View Source
var ErrIsDirectory = errors.New("error: is a directory")
View Source
var ErrNotYetImplemented = errors.New("not yet implemented")

Functions

This section is empty.

Types

type Directory

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

func NewDirectory

func NewDirectory(name string, node *dag.Node, parent childCloser, fs *Filesystem) *Directory

func (*Directory) AddChild

func (d *Directory) AddChild(name string, nd *dag.Node) error

AddChild adds the node 'nd' under this directory giving it the name 'name'

func (*Directory) Child

func (d *Directory) Child(name string) (FSNode, error)

Child returns the child of this directory by the given name

func (*Directory) GetNode

func (d *Directory) GetNode() (*dag.Node, error)

func (*Directory) List

func (d *Directory) List() []string

func (*Directory) Lock

func (d *Directory) Lock()

func (*Directory) Mkdir

func (d *Directory) Mkdir(name string) (*Directory, error)

func (*Directory) Type

func (d *Directory) Type() NodeType
func (d *Directory) Unlink(name string) error

func (*Directory) Unlock

func (d *Directory) Unlock()

type FSNode

type FSNode interface {
	GetNode() (*dag.Node, error)
	Type() NodeType
	Lock()
	Unlock()
}

FSNode represents any node (directory, root, or file) in the ipns filesystem

type File

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

func NewFile

func NewFile(name string, node *dag.Node, parent childCloser, fs *Filesystem) (*File, error)

NewFile returns a NewFile object with the given parameters

func (*File) Close

func (fi *File) Close() error

Close flushes, then propogates the modified dag node up the directory structure and signals a republish to occur

func (*File) CtxReadFull

func (fi *File) CtxReadFull(ctx context.Context, b []byte) (int, error)

Read reads into the given buffer from the current offset

func (*File) GetNode

func (fi *File) GetNode() (*dag.Node, error)

GetNode returns the dag node associated with this file

func (*File) Lock

func (fi *File) Lock()

Lock the file

func (*File) Read

func (fi *File) Read(b []byte) (int, error)

Read reads into the given buffer from the current offset

func (*File) Seek

func (fi *File) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker

func (*File) Size

func (fi *File) Size() (int64, error)

Size returns the size of this file

func (*File) Sync

func (fi *File) Sync() error

Sync flushes the changes in the file to disk

func (*File) Truncate

func (fi *File) Truncate(size int64) error

Truncate truncates the file to size

func (*File) Type

func (fi *File) Type() NodeType

Type returns the type FSNode this is

func (*File) Unlock

func (fi *File) Unlock()

Unlock the file

func (*File) Write

func (fi *File) Write(b []byte) (int, error)

Write writes the given data to the file at its current offset

func (*File) WriteAt

func (fi *File) WriteAt(b []byte, at int64) (int, error)

Write At writes the given bytes at the offset 'at'

type Filesystem

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

Filesystem is the writeable fuse filesystem structure

func NewFilesystem

func NewFilesystem(ctx context.Context, ds dag.DAGService, nsys namesys.NameSystem, pins pin.Pinner, keys ...ci.PrivKey) (*Filesystem, error)

NewFilesystem instantiates an ipns filesystem using the given parameters and locally owned keys

func (*Filesystem) Close

func (fs *Filesystem) Close() error

func (*Filesystem) GetRoot

func (fs *Filesystem) GetRoot(name string) (*KeyRoot, error)

GetRoot returns the KeyRoot of the given name

type KeyRoot

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

KeyRoot represents the root of a filesystem tree pointed to by a given keypair

func (*KeyRoot) GetValue

func (kr *KeyRoot) GetValue() FSNode

func (*KeyRoot) Publish

func (kr *KeyRoot) Publish(ctx context.Context) error

Publish publishes the ipns entry associated with this key

type NodeType

type NodeType int
const (
	TFile NodeType = iota
	TDir
)

type Republisher

type Republisher struct {
	TimeoutLong  time.Duration
	TimeoutShort time.Duration
	Publish      chan struct{}
	// contains filtered or unexported fields
}

Republisher manages when to publish the ipns entry associated with a given key

func NewRepublisher

func NewRepublisher(root *KeyRoot, tshort, tlong time.Duration) *Republisher

NewRepublisher creates a new Republisher object to republish the given keyroot using the given short and long time intervals

func (*Republisher) Run

func (np *Republisher) Run(ctx context.Context)

Run is the main republisher loop

func (*Republisher) Touch

func (np *Republisher) Touch()

Touch signals that an update has occurred since the last publish. Multiple consecutive touches may extend the time period before the next Publish occurs in order to more efficiently batch updates

Jump to

Keyboard shortcuts

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