2019-07-09 17:50:48 +00:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
2020-12-30 10:04:00 +00:00
|
|
|
"context"
|
2019-07-18 14:01:39 +00:00
|
|
|
"errors"
|
2020-06-01 16:37:10 +00:00
|
|
|
|
2019-07-09 17:50:48 +00:00
|
|
|
"github.com/ipfs/go-datastore"
|
|
|
|
"github.com/multiformats/go-multiaddr"
|
|
|
|
|
2021-02-28 22:48:36 +00:00
|
|
|
"github.com/filecoin-project/lotus/blockstore"
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2022-06-14 18:25:52 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/paths"
|
2022-06-14 18:03:38 +00:00
|
|
|
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
|
2019-07-09 17:50:48 +00:00
|
|
|
)
|
|
|
|
|
2020-11-01 13:01:26 +00:00
|
|
|
// BlockstoreDomain represents the domain of a blockstore.
|
|
|
|
type BlockstoreDomain string
|
|
|
|
|
|
|
|
const (
|
2021-02-28 22:48:36 +00:00
|
|
|
// UniversalBlockstore represents the blockstore domain for all data.
|
2020-11-01 13:01:26 +00:00
|
|
|
// Right now, this includes chain objects (tipsets, blocks, messages), as
|
2020-11-01 17:09:14 +00:00
|
|
|
// well as state. In the future, they may get segregated into different
|
2020-11-01 13:01:26 +00:00
|
|
|
// domains.
|
2021-02-28 22:48:36 +00:00
|
|
|
UniversalBlockstore = BlockstoreDomain("universal")
|
2021-02-26 13:45:30 +00:00
|
|
|
HotBlockstore = BlockstoreDomain("hot")
|
2020-11-01 13:01:26 +00:00
|
|
|
)
|
|
|
|
|
2019-07-09 17:50:48 +00:00
|
|
|
var (
|
2019-07-18 14:01:39 +00:00
|
|
|
ErrNoAPIEndpoint = errors.New("API not running (no endpoint)")
|
2019-07-23 18:49:09 +00:00
|
|
|
ErrNoAPIToken = errors.New("API token not set")
|
2020-06-01 16:37:10 +00:00
|
|
|
ErrRepoAlreadyLocked = errors.New("repo is already locked (lotus daemon already running)")
|
2019-07-18 14:01:39 +00:00
|
|
|
ErrClosedRepo = errors.New("repo is no longer open")
|
2020-11-01 13:01:26 +00:00
|
|
|
|
|
|
|
// ErrInvalidBlockstoreDomain is returned by LockedRepo#Blockstore() when
|
|
|
|
// an unrecognized domain is requested.
|
|
|
|
ErrInvalidBlockstoreDomain = errors.New("invalid blockstore domain")
|
2019-07-09 17:50:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Repo interface {
|
|
|
|
// APIEndpoint returns multiaddress for communication with Lotus API
|
|
|
|
APIEndpoint() (multiaddr.Multiaddr, error)
|
|
|
|
|
2019-07-23 18:49:09 +00:00
|
|
|
// APIToken returns JWT API Token for use in operations that require auth
|
|
|
|
APIToken() ([]byte, error)
|
|
|
|
|
2019-07-09 17:50:48 +00:00
|
|
|
// Lock locks the repo for exclusive use.
|
2019-10-30 16:38:39 +00:00
|
|
|
Lock(RepoType) (LockedRepo, error)
|
2019-07-09 17:50:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type LockedRepo interface {
|
|
|
|
// Close closes repo and removes lock.
|
|
|
|
Close() error
|
|
|
|
|
2022-05-31 09:03:03 +00:00
|
|
|
// returns the type of this repo
|
|
|
|
RepoType() RepoType
|
|
|
|
|
2019-07-09 17:50:48 +00:00
|
|
|
// Returns datastore defined in this repo.
|
2021-01-26 10:25:34 +00:00
|
|
|
// The supplied context must only be used to initialize the datastore.
|
|
|
|
// The implementation should not retain the context for usage throughout
|
|
|
|
// the lifecycle.
|
|
|
|
Datastore(ctx context.Context, namespace string) (datastore.Batching, error)
|
2019-07-09 17:50:48 +00:00
|
|
|
|
2020-11-01 13:01:26 +00:00
|
|
|
// Blockstore returns an IPLD blockstore for the requested domain.
|
2021-01-12 17:11:18 +00:00
|
|
|
// The supplied context must only be used to initialize the blockstore.
|
|
|
|
// The implementation should not retain the context for usage throughout
|
|
|
|
// the lifecycle.
|
2020-12-30 10:04:00 +00:00
|
|
|
Blockstore(ctx context.Context, domain BlockstoreDomain) (blockstore.Blockstore, error)
|
2020-11-01 13:01:26 +00:00
|
|
|
|
2021-02-28 22:48:36 +00:00
|
|
|
// SplitstorePath returns the path for the SplitStore
|
|
|
|
SplitstorePath() (string, error)
|
|
|
|
|
2019-07-09 17:50:48 +00:00
|
|
|
// Returns config in this repo
|
2020-06-09 23:37:18 +00:00
|
|
|
Config() (interface{}, error)
|
2020-06-10 16:07:47 +00:00
|
|
|
SetConfig(func(interface{})) error
|
2019-07-09 17:50:48 +00:00
|
|
|
|
2022-06-14 18:25:52 +00:00
|
|
|
GetStorage() (paths.StorageConfig, error)
|
|
|
|
SetStorage(func(*paths.StorageConfig)) error
|
2020-07-08 15:23:27 +00:00
|
|
|
Stat(path string) (fsutil.FsStat, error)
|
|
|
|
DiskUsage(path string) (int64, error)
|
2020-03-03 22:19:22 +00:00
|
|
|
|
2019-07-09 18:20:42 +00:00
|
|
|
// SetAPIEndpoint sets the endpoint of the current API
|
|
|
|
// so it can be read by API clients
|
2019-07-09 17:50:48 +00:00
|
|
|
SetAPIEndpoint(multiaddr.Multiaddr) error
|
|
|
|
|
2019-07-23 18:49:09 +00:00
|
|
|
// SetAPIToken sets JWT API Token for CLI
|
|
|
|
SetAPIToken([]byte) error
|
|
|
|
|
2019-07-18 14:01:39 +00:00
|
|
|
// KeyStore returns store of private keys for Filecoin transactions
|
2019-07-18 14:57:49 +00:00
|
|
|
KeyStore() (types.KeyStore, error)
|
2019-07-12 09:59:18 +00:00
|
|
|
|
2019-11-30 23:17:50 +00:00
|
|
|
// Path returns absolute path of the repo
|
2019-07-12 09:59:18 +00:00
|
|
|
Path() string
|
2021-02-28 22:48:36 +00:00
|
|
|
|
|
|
|
// Readonly returns true if the repo is readonly
|
|
|
|
Readonly() bool
|
2019-07-09 17:50:48 +00:00
|
|
|
}
|