repo

package
v0.9.7-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const LatestVersion uint = 3

Version is the version of repo schema that this code understands.

Variables

This section is empty.

Functions

func APIAddrFromRepoPath

func APIAddrFromRepoPath(repoPath string) (string, error)

APIAddrFromRepoPath returns the api addr from the filecoin repo

func APITokenFromRepoPath added in v0.9.7

func APITokenFromRepoPath(repoPath string) (string, error)

APIAddrFromRepoPath returns the token from the filecoin repo

func Exists

func Exists(repoPath string) (bool, error)

func InitFSRepo

func InitFSRepo(targetPath string, version uint, cfg *config.Config) error

InitFSRepo initializes a new repo at the target path with the provided configuration. The successful result creates a symlink at targetPath pointing to a sibling directory named with a timestamp and repo version number. The link path must be empty prior. If the computed actual directory exists, it must be empty.

func InitFSRepoDirect

func InitFSRepoDirect(targetPath string, version uint, cfg *config.Config) error

InitFSRepoDirect initializes a new repo at a target path, establishing a provided configuration. The target path must not exist, or must reference an empty, read/writable directory.

func MakeRepoDirName

func MakeRepoDirName(prefix string, ts time.Time, version uint, uniqueifier uint) string

MakeRepoDirName constructs a name for a concrete repo directory, which includes its version number and a timestamp. The name will begin with prefix and, if uniqueifier is non-zero, end with that (intended as an ordinal for finding a free name). E.g. ".filecoin-20190102-140425-012-1 This is exported for use by migrations.

func ReadVersion

func ReadVersion(repoPath string) (uint, error)

ReadVersion returns the unparsed (string) version from the version file in the specified repo.

func RequireMakeTempDir

func RequireMakeTempDir(t *testing.T, dirname string) string

RequireMakeTempDir ensures that a temporary directory is created

func RequireOpenTempFile

func RequireOpenTempFile(t *testing.T, suffix string) (*os.File, string)

RequireOpenTempFile is a shortcut for opening a given temp file with a given suffix, then returning both a filename and a file pointer.

func RequireReadLink(t *testing.T, path string) string

RequireReadLink reads a symlink that is expected to resolve successfully.

func RequireRemoveAll

func RequireRemoveAll(t *testing.T, path string)

RequireRemoveAll ensures that the error condition is checked when we clean up after creating a temporary directory.

func WriteVersion

func WriteVersion(p string, version uint) error

WriteVersion writes the given version to the repo version file.

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 OpenFSRepo

func OpenFSRepo(repoPath string, version uint) (*FSRepo, error)

OpenFSRepo opens an initialized fsrepo, expecting a specific version. The provided path may be to a directory, or a symbolic link pointing at a directory, which will be resolved just once at open.

func (*FSRepo) APIAddr

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

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

func (*FSRepo) APIToken added in v0.9.7

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

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

configModule returns the configuration object.

func (*FSRepo) Datastore

func (r *FSRepo) Datastore() blockstoreutil.Blockstore

Datastore returns the datastore.

func (*FSRepo) JournalPath

func (r *FSRepo) JournalPath() string

JournalPath returns the path the journal is at.

func (*FSRepo) Keystore

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

Keystore returns the keystore

func (*FSRepo) MetaDatastore

func (r *FSRepo) MetaDatastore() Datastore

func (*FSRepo) Path

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

Path returns the path the fsrepo is at

func (*FSRepo) PaychDatastore added in v0.9.1

func (r *FSRepo) PaychDatastore() Datastore

func (*FSRepo) ReplaceConfig

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

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

func (*FSRepo) Repo

func (r *FSRepo) Repo() Repo

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) SetAPIToken

func (r *FSRepo) SetAPIToken(token []byte) error

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) 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     blockstoreutil.Blockstore
	Ks    fskeystore.Keystore
	W     Datastore
	Chain Datastore
	Meta  Datastore
	Paych Datastore
	// contains filtered or unexported fields
}

MemRepo is an in-memory implementation of the repo interface.

func NewInMemoryRepo

func NewInMemoryRepo() *MemRepo

NewInMemoryRepo makes a new instance of MemRepo

func (*MemRepo) APIAddr

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

APIAddr reads the address of the running API from memory.

func (*MemRepo) APIToken added in v0.9.7

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

func (*MemRepo) ChainDatastore

func (mr *MemRepo) ChainDatastore() Datastore

ChainDatastore returns the chain datastore.

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

configModule returns the configuration object.

func (*MemRepo) Datastore

func (mr *MemRepo) Datastore() blockstoreutil.Blockstore

Datastore returns the datastore.

func (*MemRepo) JournalPath

func (mr *MemRepo) JournalPath() string

JournalPath returns a string to satisfy the repo interface.

func (*MemRepo) Keystore

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

Keystore returns the keystore.

func (*MemRepo) MetaDatastore

func (mr *MemRepo) MetaDatastore() Datastore

// ChainDatastore returns the chain datastore.

func (mr *MemRepo) MarketDatastore() Datastore {
	return mr.Market
}

ChainDatastore returns the chain datastore.

func (*MemRepo) Path

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

Path returns the default path.

func (*MemRepo) PaychDatastore added in v0.9.1

func (mr *MemRepo) PaychDatastore() Datastore

ChainDatastore returns the chain datastore.

func (*MemRepo) ReplaceConfig

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

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

func (*MemRepo) Repo

func (mr *MemRepo) Repo() Repo

repo return the repo

func (*MemRepo) SetAPIAddr

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

SetAPIAddr writes the address of the running API to memory.

func (*MemRepo) SetAPIToken

func (mr *MemRepo) SetAPIToken(token []byte) error

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 Repo

type Repo interface {
	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() blockstoreutil.Blockstore

	Keystore() fskeystore.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

	// MetaDatastore is a specific storage solution, only used to store mpool data.
	MetaDatastore() Datastore

	PaychDatastore() Datastore
	// SetJsonrpcAPIAddr sets the address of the running jsonrpc API.
	SetAPIAddr(maddr string) error

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

	// SetAPIToken set api token
	SetAPIToken(token []byte) error

	// APIToken get api token
	APIToken() (string, error)

	// Version returns the current repo version.
	Version() uint

	// Path returns the repo path.
	Path() (string, error)

	// JournalPath returns the journal path.
	JournalPath() string

	// Close shuts down the repo.
	Close() error

	// repo return the repo
	Repo() Repo
}

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