Documentation ¶
Index ¶
- Constants
- Variables
- func AddDatastoreConfigHandler(name string, dsc ConfigFromMap) error
- func CheckIpfsDir(fs afero.Fs, dir string) (string, error)
- func DefaultDatastoreConfig() config.Datastore
- func FileExists(fs afero.Fs, filename string) bool
- func GetRepoVersion(fs afero.Fs, ipfsDir string) (int, error)
- func Init(fs afero.Fs, repoPath string, conf *config.Config) error
- func IpfsDir(dir string) (string, error)
- func IsInitialized(fs afero.Fs, path string) bool
- func Load(fs afero.Fs, filename string) (*config.Config, error)
- func Open(fs afero.Fs, repoPath string) (repo.Repo, error)
- func ReadConfigFile(fs afero.Fs, filename string, cfg interface{}) error
- func Writable(fs afero.Fs, path string) error
- func WriteConfigFile(fs afero.Fs, filename string, cfg interface{}) error
- func WriteRepoVersion(fs afero.Fs, ipfsDir string, version int) error
- type AferoKeystore
- type AferoRepo
- func (r *AferoRepo) BackupConfig(prefix string) (string, error)
- func (r *AferoRepo) Close() error
- func (r *AferoRepo) Config() (*config.Config, error)
- func (r *AferoRepo) Datastore() repo.Datastore
- func (r *AferoRepo) FileManager() *filestore.FileManager
- func (r *AferoRepo) GetConfigKey(key string) (interface{}, error)
- func (r *AferoRepo) GetStorageUsage() (uint64, error)
- func (r *AferoRepo) Keystore() keystore.Keystore
- func (r *AferoRepo) SetAPIAddr(addr ma.Multiaddr) error
- func (r *AferoRepo) SetConfig(updated *config.Config) error
- func (r *AferoRepo) SetConfigKey(key string, value interface{}) error
- func (r *AferoRepo) SwarmKey() ([]byte, error)
- type ConfigFromMap
- type DatastoreConfig
- func AferoDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)
- func AnyDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)
- func LogDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)
- func MeasureDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)
- func MountDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error)
- type DiskSpec
Constants ¶
const RepoVersion = 11
version number that we are currently expecting to see
Variables ¶
var DsFs afero.Fs
var ErrClosed = errors.New("datastore is closed")
var ObjectKeySuffix = ".dsobject"
Functions ¶
func AddDatastoreConfigHandler ¶
func AddDatastoreConfigHandler(name string, dsc ConfigFromMap) error
func CheckIpfsDir ¶
CheckIpfsDir gets the ipfs directory and checks that the directory exists.
func DefaultDatastoreConfig ¶ added in v1.1.2
DefaultDatastoreConfig is an internal function exported to aid in testing.
func FileExists ¶
FileExists check if the file with the given path exits.
func GetRepoVersion ¶
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 ¶
Init initializes a new FSRepo at the given path with the provided config. TODO add support for custom datastores.
func IpfsDir ¶
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 ¶
IsInitialized returns true if the repo is initialized at provided |path|.
func ReadConfigFile ¶
ReadConfigFile reads the config from `filename` into `cfg`.
func WriteConfigFile ¶
WriteConfigFile writes the config from `cfg` into `filename`.
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
type AferoRepo ¶
type AferoRepo struct {
// contains filtered or unexported fields
}
func (*AferoRepo) BackupConfig ¶
BackupConfig creates a backup of the current configuration file using the given prefix for naming.
func (*AferoRepo) Config ¶
Config returns the ipfs configuration file from the repo. Changes made to the returned config are not automatically persisted.
func (*AferoRepo) FileManager ¶
func (r *AferoRepo) FileManager() *filestore.FileManager
FileManager returns a reference to the filestore file manager.
func (*AferoRepo) GetConfigKey ¶
GetConfigKey reads the value for the given key from the configuration in storage.
func (*AferoRepo) GetStorageUsage ¶
GetStorageUsage returns the number of bytes stored.
func (*AferoRepo) SetAPIAddr ¶
SetAPIAddr sets the API address in the repo.
func (*AferoRepo) SetConfigKey ¶
SetConfigKey sets the given key-value pair within the config and persists it to storage.
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.