storj/pkg/metainfo/kvmetainfo/metainfo.go
2019-03-22 11:01:49 +02:00

56 lines
1.3 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package kvmetainfo
import (
"github.com/zeebo/errs"
monkit "gopkg.in/spacemonkeygo/monkit.v2"
"storj.io/storj/internal/memory"
"storj.io/storj/pkg/storage/buckets"
"storj.io/storj/pkg/storage/segments"
"storj.io/storj/pkg/storage/streams"
"storj.io/storj/pkg/storj"
"storj.io/storj/storage"
"storj.io/storj/uplink/metainfo"
)
var mon = monkit.Package()
var errClass = errs.Class("kvmetainfo")
const defaultSegmentLimit = 8 // TODO
var _ storj.Metainfo = (*DB)(nil)
// DB implements metainfo database
type DB struct {
metainfo metainfo.Client
buckets buckets.Store
streams streams.Store
segments segments.Store
rootKey *storj.Key
}
// New creates a new metainfo database
func New(metainfo metainfo.Client, buckets buckets.Store, streams streams.Store, segments segments.Store, rootKey *storj.Key) *DB {
return &DB{
metainfo: metainfo,
buckets: buckets,
streams: streams,
segments: segments,
rootKey: rootKey,
}
}
// Limits returns limits for this metainfo database
func (db *DB) Limits() (storj.MetainfoLimits, error) {
return storj.MetainfoLimits{
ListLimit: storage.LookupLimit,
MinimumRemoteSegmentSize: memory.KiB.Int64(), // TODO: is this needed here?
MaximumInlineSegmentSize: memory.MiB.Int64(),
}, nil
}