lotus/node/repo/interface.go

53 lines
1.3 KiB
Go
Raw Permalink Normal View History

package repo
import (
"errors"
"github.com/ipfs/go-datastore"
"github.com/multiformats/go-multiaddr"
"github.com/filecoin-project/lotus/chain/types"
)
var (
ErrNoAPIEndpoint = errors.New("API not running (no endpoint)")
2019-07-23 18:49:09 +00:00
ErrNoAPIToken = errors.New("API token not set")
ErrRepoAlreadyLocked = errors.New("repo is already locked")
ErrClosedRepo = errors.New("repo is no longer open")
)
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)
// 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.
2019-07-10 15:38:35 +00:00
Datastore(namespace string) (datastore.Batching, error)
// Returns config in this repo
Config() (interface{}, error)
// SetAPIEndpoint sets the endpoint of the current API
// so it can be read by API clients
SetAPIEndpoint(multiaddr.Multiaddr) error
2019-07-23 18:49:09 +00:00
// SetAPIToken sets JWT API Token for CLI
SetAPIToken([]byte) error
// KeyStore returns store of private keys for Filecoin transactions
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
}