repo

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIFile is the filename containing the filecoin node's api address.
	APIFile = "api"
)
View Source
const Version uint = 1

Version is the current repo version that we require for a valid repo.

Variables

This section is empty.

Functions

func APIAddrFromFile

func APIAddrFromFile(apiFilePath string) (string, error)

APIAddrFromFile reads the address from the API file at the given path. A relevant comment from a similar function at go-ipfs/repo/fsrepo/fsrepo.go: 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 FSRepoDir

func FSRepoDir() string

FSRepoDir is a helper for getting the path to the repodir

func GetRepoDir

func GetRepoDir(repoDir string) string

GetRepoDir is a helper for either using a user provided repoDir or fetching the repoDir from FSRepoDir

func InitFSRepo

func InitFSRepo(p string, cfg *config.Config) error

InitFSRepo initializes an fsrepo at the given path using the given configuration

Types

type Datastore

type Datastore interface {
	// NB: there are other more featureful interfaces we could require here, we
	// can either force it, or just do hopeful type checks. Not all datastores
	// implement every feature.
	datastore.Batching
}

Datastore is the datastore interface provided by the repo

type FSRepo

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

FSRepo is a repo implementation backed by a filesystem.

func CreateRepo

func CreateRepo(repoDir string, cfg *config.Config) (*FSRepo, error)

CreateRepo provides a quick shorthand for initializing and opening a repo

func OpenFSRepo

func OpenFSRepo(p string) (*FSRepo, error)

OpenFSRepo opens an already initialized fsrepo at the given path

func (*FSRepo) APIAddr

func (r *FSRepo) APIAddr() (string, error)

APIAddr reads the FSRepo's api file and returns the api address

func (*FSRepo) ChainDatastore

func (r *FSRepo) ChainDatastore() Datastore

ChainDatastore returns the chain datastore.

func (*FSRepo) Close

func (r *FSRepo) Close() error

Close closes the repo.

func (*FSRepo) Config

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

Config returns the configuration object.

func (*FSRepo) Datastore

func (r *FSRepo) Datastore() Datastore

Datastore returns the datastore.

func (*FSRepo) DealsDatastore

func (r *FSRepo) DealsDatastore() Datastore

DealsDatastore returns the deals datastore.

func (*FSRepo) Keystore

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

Keystore returns the keystore

func (*FSRepo) NewFunc

func (r *FSRepo) NewFunc() string

func (*FSRepo) ReplaceConfig

func (r *FSRepo) ReplaceConfig(cfg *config.Config) error

ReplaceConfig replaces the current config with the newly passed in one.

func (*FSRepo) SealedDir

func (r *FSRepo) SealedDir() string

SealedDir satisfies node.SectorDirs

func (*FSRepo) SetAPIAddr

func (r *FSRepo) SetAPIAddr(maddr string) error

SetAPIAddr writes the address to the API file. SetAPIAddr expects parameter `port` to be of the form `:<port>`.

func (*FSRepo) SnapshotConfig

func (r *FSRepo) SnapshotConfig(cfg *config.Config) error

SnapshotConfig stores a copy `cfg` in <repo_path>/snapshots/ appending the time of snapshot to the filename.

func (*FSRepo) StagingDir

func (r *FSRepo) StagingDir() string

StagingDir satisfies node.SectorDirs

func (*FSRepo) Version

func (r *FSRepo) Version() uint

Version returns the version of the repo

func (*FSRepo) WalletDatastore

func (r *FSRepo) WalletDatastore() Datastore

WalletDatastore returns the wallet datastore.

type MemRepo

type MemRepo struct {
	C       *config.Config
	D       Datastore
	Ks      keystore.Keystore
	W       Datastore
	Chain   Datastore
	DealsDs Datastore
	// contains filtered or unexported fields
}

MemRepo is a mostly (see `stagingDir` and `sealedDir`) in-memory implementation of the Repo interface.

func NewInMemoryRepo

func NewInMemoryRepo() *MemRepo

NewInMemoryRepo makes a new instance of MemRepo

func NewInMemoryRepoWithSectorDirectories

func NewInMemoryRepoWithSectorDirectories(staging, sealedDir string) *MemRepo

NewInMemoryRepoWithSectorDirectories makes a new instance of MemRepo configured to use the provided directories as sealed and staged sector-storage.

func (*MemRepo) APIAddr

func (mr *MemRepo) APIAddr() (string, error)

APIAddr reads the address of the running API from memory.

func (*MemRepo) ChainDatastore

func (mr *MemRepo) ChainDatastore() Datastore

ChainDatastore returns the chain datastore.

func (*MemRepo) CleanupSectorDirs

func (mr *MemRepo) CleanupSectorDirs()

CleanupSectorDirs removes all sector directories and their contents.

func (*MemRepo) Close

func (mr *MemRepo) Close() error

Close deletes the temporary directories which hold staged piece data and sealed sectors.

func (*MemRepo) Config

func (mr *MemRepo) Config() *config.Config

Config returns the configuration object.

func (*MemRepo) Datastore

func (mr *MemRepo) Datastore() Datastore

Datastore returns the datastore.

func (*MemRepo) DealsDatastore

func (mr *MemRepo) DealsDatastore() Datastore

DealsDatastore returns the deals datastore for miners.

func (*MemRepo) Keystore

func (mr *MemRepo) Keystore() keystore.Keystore

Keystore returns the keystore.

func (*MemRepo) NewFunc

func (mr *MemRepo) NewFunc() string

func (*MemRepo) ReplaceConfig

func (mr *MemRepo) ReplaceConfig(cfg *config.Config) error

ReplaceConfig replaces the current config with the newly passed in one.

func (*MemRepo) SealedDir

func (mr *MemRepo) SealedDir() string

SealedDir implements node.SectorDirs.

func (*MemRepo) SetAPIAddr

func (mr *MemRepo) SetAPIAddr(addr string) error

SetAPIAddr writes the address of the running API to memory.

func (*MemRepo) StagingDir

func (mr *MemRepo) StagingDir() string

StagingDir implements node.StagingDir.

func (*MemRepo) Version

func (mr *MemRepo) Version() uint

Version returns the version of the repo.

func (*MemRepo) WalletDatastore

func (mr *MemRepo) WalletDatastore() Datastore

WalletDatastore returns the wallet datastore.

type NoRepoError

type NoRepoError struct {
	Path string
}

NoRepoError is returned when trying to open a repo where one does not exist

func (NoRepoError) Error

func (err NoRepoError) Error() string

type Repo

type Repo interface {
	NewFunc() string

	Config() *config.Config
	// ReplaceConfig replaces the current config, with the newly passed in one.
	ReplaceConfig(cfg *config.Config) error

	// Datastore is a general storage solution for things like blocks.
	Datastore() Datastore
	Keystore() keystore.Keystore

	// WalletDatastore is a specific storage solution, only used to store sensitive wallet information.
	WalletDatastore() Datastore

	// ChainDatastore is a specific storage solution, only used to store already validated chain data.
	ChainDatastore() Datastore

	// DealsDatastore holds deals data.
	DealsDatastore() Datastore

	// SetAPIAddr sets the address of the running API.
	SetAPIAddr(string) error

	// APIAddr returns the address of the running API.
	APIAddr() (string, error)

	Version() uint

	// StagingDir is used to store staged sectors.
	StagingDir() string

	// SealedDir is used to store sealed sectors.
	SealedDir() string

	Close() error
}

Repo is a representation of all persistent data in a filecoin node.

Jump to

Keyboard shortcuts

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