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"
|
|
|
|
|
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/storj"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/memory"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/uplink/eestream"
|
2019-06-24 03:06:14 +01:00
|
|
|
"storj.io/storj/uplink/metainfo"
|
2019-07-28 06:55:36 +01:00
|
|
|
"storj.io/storj/uplink/storage/segments"
|
|
|
|
"storj.io/storj/uplink/storage/streams"
|
2019-06-24 03:06:14 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
2019-10-29 15:49:16 +00:00
|
|
|
segment := segments.NewSegmentStore(m, nil, rs)
|
2019-06-24 03:06:14 +01:00
|
|
|
|
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))
|
2019-10-29 15:49:16 +00:00
|
|
|
strms, err := streams.NewStreamStore(m, segment, maxBucketMetaSize.Int64(), encStore, memory.KiB.Int(), storj.EncAESGCM, maxBucketMetaSize.Int(), maxBucketMetaSize.Int64())
|
2019-06-24 03:06:14 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, Error.New("failed to create streams: %v", err)
|
|
|
|
}
|
|
|
|
|
2019-07-12 13:57:02 +01:00
|
|
|
return NewProject(strms, memory.KiB.Int32(), rs, 64*memory.MiB.Int64(), *m), nil
|
2019-06-24 03:06:14 +01:00
|
|
|
}
|