datastore.go 1006 Bytes
Newer Older
1 2
package config

Tommi Virtanen's avatar
Tommi Virtanen committed
3 4 5 6
import (
	"encoding/json"
)

7 8 9 10 11
// DefaultDataStoreDirectory is the directory to store all the local IPFS data.
const DefaultDataStoreDirectory = "datastore"

// Datastore tracks the configuration of the datastore.
type Datastore struct {
rht's avatar
rht committed
12 13 14 15 16
	Type               string
	Path               string
	StorageMax         string // in B, kB, kiB, MB, ...
	StorageGCWatermark int64  // in percentage to multiply on StorageMax
	GCPeriod           string // in ns, us, ms, s, m, h
Tommi Virtanen's avatar
Tommi Virtanen committed
17 18

	Params *json.RawMessage
rht's avatar
rht committed
19
	NoSync bool
Tommi Virtanen's avatar
Tommi Virtanen committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33
}

func (d *Datastore) ParamData() []byte {
	if d.Params == nil {
		return nil
	}

	return []byte(*d.Params)
}

type S3Datastore struct {
	Region string `json:"region"`
	Bucket string `json:"bucket"`
	ACL    string `json:"acl"`
34 35 36 37 38 39 40
}

// DataStorePath returns the default data store path given a configuration root
// (set an empty string to have the default configuration root)
func DataStorePath(configroot string) (string, error) {
	return Path(configroot, DefaultDataStoreDirectory)
}