-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo.go
64 lines (47 loc) · 1.92 KB
/
repo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package repo
import (
"errors"
"io"
filestore "github.com/ipfs/go-ipfs/filestore"
keystore "github.com/ipfs/go-ipfs/keystore"
config "github.com/ipfs/go-ipfs/repo/config"
ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr"
ds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore"
)
var (
ErrApiNotRunning = errors.New("api not running")
)
// Repo represents all persistent data of a given ipfs node.
type Repo interface {
// Config returns the ipfs configuration file from the repo. Changes made
// to the returned config are not automatically persisted.
Config() (*config.Config, error)
// BackupConfig creates a backup of the current configuration file using
// the given prefix for naming.
BackupConfig(prefix string) (string, error)
// SetConfig persists the given configuration struct to storage.
SetConfig(*config.Config) error
// SetConfigKey sets the given key-value pair within the config and persists it to storage.
SetConfigKey(key string, value interface{}) error
// GetConfigKey reads the value for the given key from the configuration in storage.
GetConfigKey(key string) (interface{}, error)
// Datastore returns a reference to the configured data storage backend.
Datastore() Datastore
// GetStorageUsage returns the number of bytes stored.
GetStorageUsage() (uint64, error)
// Keystore returns a reference to the key management interface.
Keystore() keystore.Keystore
// FileManager returns a reference to the filestore file manager.
FileManager() *filestore.FileManager
// SetAPIAddr sets the API address in the repo.
SetAPIAddr(addr ma.Multiaddr) error
// SwarmKey returns the configured shared symmetric key for the private networks feature.
SwarmKey() ([]byte, error)
io.Closer
}
// Datastore is the interface required from a datastore to be
// acceptable to FSRepo.
type Datastore interface {
ds.Batching // should be threadsafe, just be careful
io.Closer
}