go-ipfs: github.com/ipfs/go-ipfs/repo/fsrepo Index | Files | Directories

package fsrepo

import "github.com/ipfs/go-ipfs/repo/fsrepo"

package fsrepo

TODO explain the package roadmap...

.ipfs/
├── client/
|   ├── client.lock          <------ protects client/ + signals its own pid
│   ├── ipfs-client.cpuprof
│   └── ipfs-client.memprof
├── config
├── daemon/
│   ├── daemon.lock          <------ protects daemon/ + signals its own address
│   ├── ipfs-daemon.cpuprof
│   └── ipfs-daemon.memprof
├── datastore/
├── repo.lock                <------ protects datastore/ and config
└── version

Index

Package Files

datastores.go doc.go fsrepo.go misc.go

Constants

const LockFile = "repo.lock"

LockFile is the filename of the repo lock, relative to config dir TODO rename repo lock and hide name

Variables

var (
    ErrNoVersion     = errors.New("no version file found, please run 0-to-1 migration tool.\n" + migrationInstructions)
    ErrOldRepo       = errors.New("ipfs repo found in old '~/.go-ipfs' location, please run migration tool.\n" + migrationInstructions)
    ErrNeedMigration = errors.New("ipfs repo needs migration")
)
var RepoVersion = 7

version number that we are currently expecting to see

func APIAddr Uses

func APIAddr(repoPath string) (ma.Multiaddr, error)

APIAddr returns the registered API addr, according to the api file in the fsrepo. This is a concurrent operation, meaning that any process may read this file. modifying this file, therefore, should use "mv" to replace the whole file and avoid interleaved read/writes.

func AddDatastoreConfigHandler Uses

func AddDatastoreConfigHandler(name string, dsc ConfigFromMap) error

func BestKnownPath Uses

func BestKnownPath() (string, error)

BestKnownPath returns the best known fsrepo path. If the ENV override is present, this function returns that value. Otherwise, it returns the default repo path.

func ConfigAt Uses

func ConfigAt(repoPath string) (*config.Config, error)

ConfigAt returns an error if the FSRepo at the given path is not initialized. This function allows callers to read the config file even when another process is running and holding the lock.

func Init Uses

func Init(repoPath string, conf *config.Config) error

Init initializes a new FSRepo at the given path with the provided config. TODO add support for custom datastores.

func IsInitialized Uses

func IsInitialized(path string) bool

IsInitialized returns true if the repo is initialized at provided |path|.

func LockedByOtherProcess Uses

func LockedByOtherProcess(repoPath string) (bool, error)

LockedByOtherProcess returns true if the FSRepo is locked by another process. If true, then the repo cannot be opened by this process.

func Open Uses

func Open(repoPath string) (repo.Repo, error)

Open the FSRepo at path. Returns an error if the repo is not initialized.

type ConfigFromMap Uses

type ConfigFromMap func(map[string]interface{}) (DatastoreConfig, error)

ConfigFromMap creates a new datastore config from a map

type DatastoreConfig Uses

type DatastoreConfig interface {
    // DiskSpec returns a minimal configuration of the datastore
    // represting what is stored on disk.  Run time values are
    // excluded.
    DiskSpec() DiskSpec

    // Create instantiate a new datastore from this config
    Create(path string) (repo.Datastore, error)
}

DatastoreConfig is an abstraction of a datastore config. A "spec" is first converted to a DatastoreConfig and then Create() is called to instantiate a new datastore

func AnyDatastoreConfig Uses

func AnyDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)

AnyDatastoreConfig returns a DatastoreConfig from a spec based on the "type" parameter

func LogDatastoreConfig Uses

func LogDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)

LogDatastoreConfig returns a log DatastoreConfig from a spec

func MeasureDatastoreConfig Uses

func MeasureDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)

MeasureDatastoreConfig returns a measure DatastoreConfig from a spec

func MemDatastoreConfig Uses

func MemDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)

MemDatastoreConfig returns a memory DatastoreConfig from a spec

func MountDatastoreConfig Uses

func MountDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)

MountDatastoreConfig returns a mount DatastoreConfig from a spec

type DiskSpec Uses

type DiskSpec map[string]interface{}

DiskSpec is a minimal representation of the characteristic values of the datastore. If two diskspecs are the same, the loader assumes that they refer to exactly the same datastore. If they differ at all, it is assumed they are completely different datastores and a migration will be performed. Runtime values such as cache options or concurrency options should not be added here.

func (DiskSpec) Bytes Uses

func (spec DiskSpec) Bytes() []byte

Bytes returns a minimal JSON encoding of the DiskSpec

func (DiskSpec) String Uses

func (spec DiskSpec) String() string

String returns a minimal JSON encoding of the DiskSpec

type FSRepo Uses

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

FSRepo represents an IPFS FileSystem Repo. It is safe for use by multiple callers.

func (*FSRepo) BackupConfig Uses

func (r *FSRepo) BackupConfig(prefix string) (string, error)

func (*FSRepo) Close Uses

func (r *FSRepo) Close() error

Close closes the FSRepo, releasing held resources.

func (*FSRepo) Config Uses

func (r *FSRepo) Config() (*config.Config, error)

Config the current config. This function DOES NOT copy the config. The caller MUST NOT modify it without first calling `Clone`.

Result when not Open is undefined. The method may panic if it pleases.

func (*FSRepo) Datastore Uses

func (r *FSRepo) Datastore() repo.Datastore

Datastore returns a repo-owned datastore. If FSRepo is Closed, return value is undefined.

func (*FSRepo) FileManager Uses

func (r *FSRepo) FileManager() *filestore.FileManager

func (*FSRepo) GetConfigKey Uses

func (r *FSRepo) GetConfigKey(key string) (interface{}, error)

GetConfigKey retrieves only the value of a particular key.

func (*FSRepo) GetStorageUsage Uses

func (r *FSRepo) GetStorageUsage() (uint64, error)

GetStorageUsage computes the storage space taken by the repo in bytes

func (*FSRepo) Keystore Uses

func (r *FSRepo) Keystore() keystore.Keystore

func (*FSRepo) Path Uses

func (r *FSRepo) Path() string

func (*FSRepo) SetAPIAddr Uses

func (r *FSRepo) SetAPIAddr(addr ma.Multiaddr) error

SetAPIAddr writes the API Addr to the /api file.

func (*FSRepo) SetConfig Uses

func (r *FSRepo) SetConfig(updated *config.Config) error

SetConfig updates the FSRepo's config. The user must not modify the config object after calling this method.

func (*FSRepo) SetConfigKey Uses

func (r *FSRepo) SetConfigKey(key string, value interface{}) error

SetConfigKey writes the value of a particular key.

func (*FSRepo) SwarmKey Uses

func (r *FSRepo) SwarmKey() ([]byte, error)

type NoRepoError Uses

type NoRepoError struct {
    Path string
}

func (NoRepoError) Error Uses

func (err NoRepoError) Error() string

Directories

PathSynopsis
migrations

Package fsrepo imports 29 packages (graph) and is imported by 167 packages. Updated 2019-09-02. Refresh now. Tools for package owners.