repo

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0, MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const RepoVersion = 11

version number that we are currently expecting to see

Variables

View Source
var DsFs afero.Fs
View Source
var ErrClosed = errors.New("datastore is closed")
View Source
var ObjectKeySuffix = ".dsobject"

Functions

func AddDatastoreConfigHandler

func AddDatastoreConfigHandler(name string, dsc ConfigFromMap) error

func CheckIpfsDir

func CheckIpfsDir(fs afero.Fs, dir string) (string, error)

CheckIpfsDir gets the ipfs directory and checks that the directory exists.

func DefaultDatastoreConfig added in v1.1.2

func DefaultDatastoreConfig() config.Datastore

DefaultDatastoreConfig is an internal function exported to aid in testing.

func FileExists

func FileExists(fs afero.Fs, filename string) bool

FileExists check if the file with the given path exits.

func GetRepoVersion

func GetRepoVersion(fs afero.Fs, ipfsDir string) (int, error)

GetRepoVersion returns the version of the repo in the ipfs directory. If the ipfs directory is not specified then the default location is used.

func Init

func Init(fs afero.Fs, 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 IpfsDir

func IpfsDir(dir string) (string, error)

IpfsDir returns the path of the ipfs directory. If dir specified, then returns the expanded version dir. If dir is "", then return the directory set by IPFS_PATH, or if IPFS_PATH is not set, then return the default location in the home directory.

func IsInitialized

func IsInitialized(fs afero.Fs, path string) bool

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

func Load

func Load(fs afero.Fs, filename string) (*config.Config, error)

Load reads given file and returns the read config, or error.

func Open

func Open(fs afero.Fs, repoPath string) (repo.Repo, error)

func ReadConfigFile

func ReadConfigFile(fs afero.Fs, filename string, cfg interface{}) error

ReadConfigFile reads the config from `filename` into `cfg`.

func Writable

func Writable(fs afero.Fs, path string) error

Writable ensures the directory exists and is writable

func WriteConfigFile

func WriteConfigFile(fs afero.Fs, filename string, cfg interface{}) error

WriteConfigFile writes the config from `cfg` into `filename`.

func WriteRepoVersion

func WriteRepoVersion(fs afero.Fs, ipfsDir string, version int) error

WriteRepoVersion writes the specified repo version to the repo located in ipfsDir. If ipfsDir is not specified, then the default location is used.

Types

type AferoKeystore

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

AferoKeystore is a keystore backed by files in a given directory stored on disk.

func NewAferoKeystore

func NewAferoKeystore(fs afero.Fs, dir string) (*AferoKeystore, error)

NewAferoKeystore returns a new filesystem-backed keystore.

func (*AferoKeystore) Delete

func (ks *AferoKeystore) Delete(name string) error

Delete removes a key from the Keystore

func (*AferoKeystore) Get

func (ks *AferoKeystore) Get(name string) (ci.PrivKey, error)

Get retrieves a key from the Keystore if it exists, and returns ErrNoSuchKey otherwise.

func (*AferoKeystore) Has

func (ks *AferoKeystore) Has(name string) (bool, error)

Has returns whether or not a key exists in the Keystore

func (*AferoKeystore) List

func (ks *AferoKeystore) List() ([]string, error)

List return a list of key identifier

func (*AferoKeystore) Put

func (ks *AferoKeystore) Put(name string, k ci.PrivKey) error

Put stores a key in the Keystore, if a key with the same name already exists, returns ErrKeyExists

type AferoRepo

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

func (*AferoRepo) BackupConfig

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

BackupConfig creates a backup of the current configuration file using the given prefix for naming.

func (*AferoRepo) Close

func (r *AferoRepo) Close() error

Close see io.Closer

func (*AferoRepo) Config

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

Config returns the ipfs configuration file from the repo. Changes made to the returned config are not automatically persisted.

func (*AferoRepo) Datastore

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

Datastore returns a reference to the configured data storage backend.

func (*AferoRepo) FileManager

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

FileManager returns a reference to the filestore file manager.

func (*AferoRepo) GetConfigKey

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

GetConfigKey reads the value for the given key from the configuration in storage.

func (*AferoRepo) GetStorageUsage

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

GetStorageUsage returns the number of bytes stored.

func (*AferoRepo) Keystore

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

Keystore returns a reference to the key management interface.

func (*AferoRepo) SetAPIAddr

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

SetAPIAddr sets the API address in the repo.

func (*AferoRepo) SetConfig

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

SetConfig persists the given configuration struct to storage.

func (*AferoRepo) SetConfigKey

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

SetConfigKey sets the given key-value pair within the config and persists it to storage.

func (*AferoRepo) SwarmKey

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

SwarmKey returns the configured shared symmetric key for the private networks feature.

type ConfigFromMap

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

ConfigFromMap creates a new datastore config from a map

type DatastoreConfig

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 AferoDatastoreConfig

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

AferoDatastoreConfig returns an afero DatastoreConfig from a spec

func AnyDatastoreConfig

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

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

func LogDatastoreConfig

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

LogDatastoreConfig returns a log DatastoreConfig from a spec

func MeasureDatastoreConfig

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

MeasureDatastoreConfig returns a measure DatastoreConfig from a spec

func MountDatastoreConfig

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

MountDatastoreConfig returns a mount DatastoreConfig from a spec

type DiskSpec

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

func (spec DiskSpec) Bytes() []byte

Bytes returns a minimal JSON encoding of the DiskSpec

func (DiskSpec) String

func (spec DiskSpec) String() string

String returns a minimal JSON encoding of the DiskSpec

Jump to

Keyboard shortcuts

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