5d0816430f
* rename pkg/linksharing to linksharing * rename pkg/httpserver to linksharing/httpserver * rename pkg/eestream to uplink/eestream * rename pkg/stream to uplink/stream * rename pkg/metainfo/kvmetainfo to uplink/metainfo/kvmetainfo * rename pkg/auth/signing to pkg/signing * rename pkg/storage to uplink/storage * rename pkg/accounting to satellite/accounting * rename pkg/audit to satellite/audit * rename pkg/certdb to satellite/certdb * rename pkg/discovery to satellite/discovery * rename pkg/overlay to satellite/overlay * rename pkg/datarepair to satellite/repair
51 lines
1.8 KiB
Go
51 lines
1.8 KiB
Go
// 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/encryption"
|
|
"storj.io/storj/pkg/storj"
|
|
"storj.io/storj/uplink/eestream"
|
|
"storj.io/storj/uplink/metainfo"
|
|
"storj.io/storj/uplink/storage/segments"
|
|
"storj.io/storj/uplink/storage/streams"
|
|
)
|
|
|
|
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
|
|
func SetupProject(m *metainfo.Client) (*Project, error) {
|
|
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())
|
|
|
|
// 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.EncAESGCM, maxBucketMetaSize.Int())
|
|
if err != nil {
|
|
return nil, Error.New("failed to create streams: %v", err)
|
|
}
|
|
|
|
return NewProject(strms, memory.KiB.Int32(), rs, 64*memory.MiB.Int64(), *m), nil
|
|
}
|