2019-06-24 03:06:14 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package kvmetainfo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/vivint/infectious"
|
|
|
|
"github.com/zeebo/errs"
|
|
|
|
|
|
|
|
"storj.io/storj/internal/memory"
|
|
|
|
"storj.io/storj/pkg/eestream"
|
2019-06-24 20:23:07 +01:00
|
|
|
"storj.io/storj/pkg/encryption"
|
2019-06-24 03:06:14 +01:00
|
|
|
"storj.io/storj/pkg/storage/segments"
|
|
|
|
"storj.io/storj/pkg/storage/streams"
|
|
|
|
"storj.io/storj/pkg/storj"
|
|
|
|
"storj.io/storj/uplink/metainfo"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// Error is the errs class of SetupProject
|
|
|
|
Error = errs.Class("SetupProject error")
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetupProject creates a project with temporary values until we can figure out how to bypass encryption related setup
|
2019-06-25 16:36:23 +01:00
|
|
|
func SetupProject(m *metainfo.Client) (*Project, error) {
|
2019-06-24 03:06:14 +01:00
|
|
|
whoCares := 1 // TODO: find a better way to do this
|
|
|
|
fc, err := infectious.NewFEC(whoCares, whoCares)
|
|
|
|
if err != nil {
|
|
|
|
return nil, Error.New("failed to create erasure coding client: %v", err)
|
|
|
|
}
|
|
|
|
rs, err := eestream.NewRedundancyStrategy(eestream.NewRSScheme(fc, whoCares), whoCares, whoCares)
|
|
|
|
if err != nil {
|
|
|
|
return nil, Error.New("failed to create redundancy strategy: %v", err)
|
|
|
|
}
|
|
|
|
maxBucketMetaSize := 10 * memory.MiB
|
|
|
|
segment := segments.NewSegmentStore(m, nil, rs, maxBucketMetaSize.Int(), maxBucketMetaSize.Int64())
|
|
|
|
|
2019-06-24 20:23:07 +01:00
|
|
|
// volatile warning: we're setting an encryption key of all zeros for bucket
|
|
|
|
// metadata, when really the bucket metadata should be stored in a different
|
|
|
|
// system altogether.
|
|
|
|
// TODO: https://storjlabs.atlassian.net/browse/V3-1967
|
|
|
|
encStore := encryption.NewStore()
|
|
|
|
encStore.SetDefaultKey(new(storj.Key))
|
|
|
|
strms, err := streams.NewStreamStore(segment, maxBucketMetaSize.Int64(), encStore, memory.KiB.Int(), storj.AESGCM, maxBucketMetaSize.Int())
|
2019-06-24 03:06:14 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, Error.New("failed to create streams: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return NewProject(strms, memory.KiB.Int32(), rs, 64*memory.MiB.Int64()), nil
|
|
|
|
}
|