81 lines
2.4 KiB
Go
81 lines
2.4 KiB
Go
package repo
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/filecoin-project/lotus/lib/blockstore"
|
|
"github.com/ipfs/go-datastore"
|
|
"github.com/multiformats/go-multiaddr"
|
|
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
)
|
|
|
|
// BlockstoreDomain represents the domain of a blockstore.
|
|
type BlockstoreDomain string
|
|
|
|
const (
|
|
// BlockstoreChain represents the blockstore domain for chain data.
|
|
// Right now, this includes chain objects (tipsets, blocks, messages), as
|
|
// well as state. In the future, they may get segregated into different
|
|
// domains.
|
|
BlockstoreChain = BlockstoreDomain("chain")
|
|
)
|
|
|
|
var (
|
|
ErrNoAPIEndpoint = errors.New("API not running (no endpoint)")
|
|
ErrNoAPIToken = errors.New("API token not set")
|
|
ErrRepoAlreadyLocked = errors.New("repo is already locked (lotus daemon already running)")
|
|
ErrClosedRepo = errors.New("repo is no longer open")
|
|
|
|
// ErrInvalidBlockstoreDomain is returned by LockedRepo#Blockstore() when
|
|
// an unrecognized domain is requested.
|
|
ErrInvalidBlockstoreDomain = errors.New("invalid blockstore domain")
|
|
)
|
|
|
|
type Repo interface {
|
|
// APIEndpoint returns multiaddress for communication with Lotus API
|
|
APIEndpoint() (multiaddr.Multiaddr, error)
|
|
|
|
// APIToken returns JWT API Token for use in operations that require auth
|
|
APIToken() ([]byte, error)
|
|
|
|
// Lock locks the repo for exclusive use.
|
|
Lock(RepoType) (LockedRepo, error)
|
|
}
|
|
|
|
type LockedRepo interface {
|
|
// Close closes repo and removes lock.
|
|
Close() error
|
|
|
|
// Returns datastore defined in this repo.
|
|
Datastore(namespace string) (datastore.Batching, error)
|
|
|
|
// Blockstore returns an IPLD blockstore for the requested domain.
|
|
Blockstore(domain BlockstoreDomain) (blockstore.Blockstore, error)
|
|
|
|
// Returns config in this repo
|
|
Config() (interface{}, error)
|
|
SetConfig(func(interface{})) error
|
|
|
|
GetStorage() (stores.StorageConfig, error)
|
|
SetStorage(func(*stores.StorageConfig)) error
|
|
Stat(path string) (fsutil.FsStat, error)
|
|
DiskUsage(path string) (int64, error)
|
|
|
|
// SetAPIEndpoint sets the endpoint of the current API
|
|
// so it can be read by API clients
|
|
SetAPIEndpoint(multiaddr.Multiaddr) error
|
|
|
|
// SetAPIToken sets JWT API Token for CLI
|
|
SetAPIToken([]byte) error
|
|
|
|
// KeyStore returns store of private keys for Filecoin transactions
|
|
KeyStore() (types.KeyStore, error)
|
|
|
|
// Path returns absolute path of the repo
|
|
Path() string
|
|
}
|