[#291] Remove some unused code from repository

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-29 18:50:41 +03:00 committed by Alex Vanin
parent a51211eda7
commit 9a86fff7e0
23 changed files with 14 additions and 399 deletions

View file

@ -220,9 +220,6 @@ func completeBearerToken(btok *token.BearerToken) error {
// set eACL table version, because it usually omitted
table := v2.GetBody().GetEACL()
table.SetVersion(pkg.SDKVersion().ToV2())
// back to SDK token
btok = token.NewBearerTokenFromV2(v2)
} else {
return errors.New("unsupported bearer token version")
}

View file

@ -20,8 +20,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/container"
netmapCore "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket/fsbucket"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
@ -562,26 +560,6 @@ func configPath(sections ...string) string {
return strings.Join(sections, ".")
}
func initBucket(prefix string, c *cfg) (bucket bucket.Bucket, err error) {
const inmemory = "inmemory"
switch c.viper.GetString(prefix + ".type") {
case inmemory:
bucket = newBucket()
c.log.Info("using in-memory bucket", zap.String("storage", prefix))
case fsbucket.Name:
bucket, err = fsbucket.NewBucket(prefix, c.viper)
if err != nil {
return nil, errors.Wrap(err, "can't create fs bucket")
}
c.log.Info("using filesystem bucket", zap.String("storage", prefix))
default:
return nil, errors.New("unknown storage type")
}
return bucket, nil
}
func initObjectPool(cfg *viper.Viper) (pool cfgObjectRoutines) {
var err error

View file

@ -20,8 +20,9 @@ func initGRPC(c *cfg) {
}
func serveGRPC(c *cfg) {
c.wg.Add(1)
go func() {
c.wg.Add(1)
defer func() {
c.wg.Done()
}()

View file

@ -2,17 +2,13 @@ package main
import (
"context"
"errors"
"sync"
"github.com/mr-tron/base58"
"github.com/nspcc-dev/neofs-api-go/pkg/client"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
"github.com/nspcc-dev/neofs-api-go/v2/object"
objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
objectCore "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/bucket"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
@ -48,12 +44,6 @@ type objectSvc struct {
delete *deletesvcV2.Service
}
type inMemBucket struct {
bucket.Bucket
*sync.RWMutex
items map[string][]byte
}
func (c *cfg) MaxObjectSize() uint64 {
sz, err := c.cfgNetmap.wrapper.MaxObjectSize()
if err != nil {
@ -65,73 +55,6 @@ func (c *cfg) MaxObjectSize() uint64 {
return sz
}
func newBucket() bucket.Bucket {
return &inMemBucket{
RWMutex: new(sync.RWMutex),
items: map[string][]byte{},
}
}
func (b *inMemBucket) Del(key []byte) error {
b.Lock()
delete(b.items, base58.Encode(key))
b.Unlock()
return nil
}
func (b *inMemBucket) Get(key []byte) ([]byte, error) {
b.RLock()
v, ok := b.items[base58.Encode(key)]
b.RUnlock()
if !ok {
return nil, errors.New("not found")
}
return v, nil
}
func (b *inMemBucket) Set(key, value []byte) error {
k := base58.Encode(key)
b.Lock()
b.items[k] = makeCopy(value)
b.Unlock()
return nil
}
func (b *inMemBucket) Iterate(handler bucket.FilterHandler) error {
if handler == nil {
return bucket.ErrNilFilterHandler
}
b.RLock()
for key, val := range b.items {
k, err := base58.Decode(key)
if err != nil {
panic(err)
}
v := makeCopy(val)
if !handler(k, v) {
return bucket.ErrIteratingAborted
}
}
b.RUnlock()
return nil
}
func makeCopy(val []byte) []byte {
tmp := make([]byte, len(val))
copy(tmp, val)
return tmp
}
func (s *objectSvc) Put(ctx context.Context) (object.PutObjectStreamer, error) {
return s.put.Put(ctx)
}

View file

@ -25,4 +25,3 @@ var (
// Debug is an application debug mode flag.
Debug = "false"
)

View file

@ -1,8 +1,6 @@
package netmap
import (
"errors"
"github.com/nspcc-dev/neofs-api-go/pkg/netmap"
)
@ -21,9 +19,6 @@ type Source interface {
GetNetMap(diff uint64) (*netmap.Netmap, error)
}
// ErrNotFound is the error returned when network map was not found in storage.
var ErrNotFound = errors.New("network map not found")
// GetLatestNetworkMap requests and returns latest network map from storage.
func GetLatestNetworkMap(src Source) (*netmap.Netmap, error) {
return src.GetNetMap(0)

View file

@ -60,14 +60,12 @@ type (
}
contracts struct {
neofs util.Uint160 // in mainnet
netmap util.Uint160 // in morph
balance util.Uint160 // in morph
container util.Uint160 // in morph
audit util.Uint160 // in morph
reputation util.Uint160 // in morph
neofsid util.Uint160 // in morph
gas util.Uint160 // native contract in both chains
neofs util.Uint160 // in mainnet
netmap util.Uint160 // in morph
balance util.Uint160 // in morph
container util.Uint160 // in morph
audit util.Uint160 // in morph
gas util.Uint160 // native contract in both chains
alphabet [alphabetContractsN]util.Uint160 // in morph
}

View file

@ -6,14 +6,6 @@ import (
)
type (
// TransferXParams for TransferBalanceX invocation.
TransferXParams struct {
Sender []byte
Receiver []byte
Amount int64 // in Fixed16
Comment []byte
}
// LockParams for LockAsset invocation.
LockParams struct {
ID []byte
@ -39,20 +31,6 @@ const (
precisionMethod = "decimals"
)
// TransferBalanceX invokes transferX method.
func TransferBalanceX(cli *client.Client, con util.Uint160, p *TransferXParams) error {
if cli == nil {
return client.ErrNilClient
}
return cli.Invoke(con, extraFee, transferXMethod,
p.Sender,
p.Receiver,
p.Amount,
p.Comment,
)
}
// Mint assets in contract.
func Mint(cli *client.Client, con util.Uint160, p *MintBurnParams) error {
if cli == nil {

View file

@ -4,7 +4,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/pkg/errors"
)
type (
@ -22,8 +21,6 @@ type (
}
)
var ErrParseTestInvoke = errors.New("can't parse NEO node response")
const (
putContainerMethod = "put"
deleteContainerMethod = "delete"

View file

@ -39,27 +39,6 @@ const (
chequeMethod = "cheque"
)
// IsInnerRing returns true if 'key' is presented in inner ring list.
func IsInnerRing(cli *client.Client, con util.Uint160, key *ecdsa.PublicKey) (bool, error) {
if cli == nil {
return false, client.ErrNilClient
}
pubKey := crypto.MarshalPublicKey(key)
val, err := cli.TestInvoke(con, checkIsInnerRingMethod, pubKey)
if err != nil {
return false, err
}
isInnerRing, err := client.BoolFromStackItem(val[0])
if err != nil {
return false, err
}
return isInnerRing, nil
}
// CashOutCheque invokes Cheque method.
func CashOutCheque(cli *client.Client, con util.Uint160, p *ChequeParams) error {
if cli == nil {

View file

@ -7,11 +7,14 @@ import (
func (ap *Processor) handleNewAuditRound(ev event.Event) {
auditEvent := ev.(Start)
ap.log.Info("new round of audit", zap.Uint64("epoch", auditEvent.epoch))
epoch := auditEvent.Epoch()
ap.log.Info("new round of audit", zap.Uint64("epoch", epoch))
// send event to the worker pool
err := ap.pool.Submit(func() { ap.processStartAudit(auditEvent.epoch) })
err := ap.pool.Submit(func() { ap.processStartAudit(epoch) })
if err != nil {
ap.log.Warn("previous round of audit prepare hasn't finished yet")
}

View file

@ -101,10 +101,3 @@ func WithLogger(l *logger.Logger) Option {
c.log = l.With(zap.String("component", "Blobovnicza"))
}
}
// WithBoltDBOptions returns option to specify BoltDB options.
func WithBoltDBOptions(opts *bbolt.Options) Option {
return func(c *cfg) {
c.boltOptions = opts
}
}

View file

@ -34,26 +34,6 @@ func testAddress() *objectSDK.Address {
return addr
}
func testObject(sz uint64) *object.Object {
raw := object.NewRaw()
addr := testAddress()
raw.SetID(addr.ObjectID())
raw.SetContainerID(addr.ContainerID())
raw.SetPayload(make([]byte, sz))
// fit the binary size to the required
data, _ := raw.Marshal()
if ln := uint64(len(data)); ln > sz {
raw.SetPayload(raw.Payload()[:sz-(ln-sz)])
}
raw.SetAttributes() // for require.Equal
return raw.Object()
}
func testPutGet(t *testing.T, blz *Blobovnicza, sz uint64, expPut, expGet error) *objectSDK.Address {
// create binary object
data := make([]byte, sz)

View file

@ -1,18 +0,0 @@
package network
import (
"net"
"github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
)
// Listen announces on the local network address.
func Listen(addr multiaddr.Multiaddr) (net.Listener, error) {
mLis, err := manet.Listen(addr)
if err != nil {
return nil, err
}
return manet.NetListener(mLis), nil
}

View file

@ -27,8 +27,6 @@ type cfg struct {
ctxPrm auditor.ContextPrm
reporter audit.Reporter
workerPool util.WorkerPool
pdpPoolGenerator, porPoolGenerator func() (util.WorkerPool, error)

View file

@ -113,7 +113,6 @@ type accessErr struct {
var (
ErrMalformedRequest = errors.New("malformed request")
ErrInternal = errors.New("internal error")
ErrUnknownRole = errors.New("can't classify request sender")
ErrUnknownContainer = errors.New("can't fetch container info")
)

View file

@ -2,9 +2,7 @@ package deletesvc
import (
"context"
"crypto/ecdsa"
"github.com/nspcc-dev/neofs-api-go/pkg/client"
"github.com/nspcc-dev/neofs-api-go/pkg/container"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -59,10 +57,6 @@ func (exec execCtx) isLocal() bool {
return exec.prm.common.LocalOnly()
}
func (exec *execCtx) key() *ecdsa.PrivateKey {
return exec.prm.common.PrivateKey()
}
func (exec *execCtx) address() *objectSDK.Address {
return exec.prm.Address()
}
@ -75,10 +69,6 @@ func (exec *execCtx) commonParameters() *util.CommonPrm {
return exec.prm.common
}
func (exec execCtx) callOptions() []client.CallOption {
return exec.prm.common.RemoteCallOptions()
}
func (exec *execCtx) newAddress(id *objectSDK.ID) *objectSDK.Address {
a := objectSDK.NewAddress()
a.SetObjectID(id)

View file

@ -106,19 +106,6 @@ func (c *testClient) getObject(exec *execCtx) (*objectSDK.Object, error) {
return cutToRange(v.obj.Object(), exec.ctxRange()).SDK(), nil
}
func (c *testClient) head(_ context.Context, p Prm) (*object.Object, error) {
v, ok := c.results[p.Address().String()]
if !ok {
return nil, object.ErrNotFound
}
if v.err != nil {
return nil, v.err
}
return v.obj.CutPayload().Object(), nil
}
func (c *testClient) addResult(addr *objectSDK.Address, obj *object.RawObject, err error) {
c.results[addr.String()] = struct {
obj *object.RawObject

View file

@ -104,9 +104,7 @@ func (c *clientWrapper) getObject(exec *execCtx) (*objectSDK.Object, error) {
return payloadOnlyObject(data), nil
} else {
return c.client.GetObject(exec.context(),
new(client.GetObjectParams).
WithAddress(exec.address()).
WithRawFlag(exec.isRaw()),
exec.remotePrm(),
exec.callOptions()...,
)
}

View file

@ -6,11 +6,6 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/object"
"github.com/nspcc-dev/neofs-node/pkg/services/util"
"github.com/pkg/errors"
)
var (
errChunking = errors.New("can't split message to stream chunks")
)
type (
@ -183,10 +178,3 @@ func (s *searchStreamMsgSizeCtrl) Send(resp *object.SearchResponse) error {
return nil
}
func min(a, b int) int {
if a > b {
return b
}
return a
}

View file

@ -9,24 +9,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/object"
)
type RangeTraverser struct {
chain *rangeChain
seekBounds *rangeBounds
}
type rangeBounds struct {
left, right uint64
}
type rangeChain struct {
next, prev *rangeChain
bounds *rangeBounds
id *objectSDK.ID
}
// HeadReceiver is an interface of entity that can receive
// object header or the information about the object relations.
type HeadReceiver interface {
@ -188,112 +170,3 @@ func traverseSplitChain(r HeadReceiver, addr *objectSDK.Address, h SplitMemberHa
return false, nil
}
func NewRangeTraverser(originSize uint64, rightElement *object.Object, rngSeek *objectSDK.Range) *RangeTraverser {
right := &rangeChain{
bounds: &rangeBounds{
left: originSize - rightElement.PayloadSize(),
right: originSize,
},
id: rightElement.ID(),
}
left := &rangeChain{
id: rightElement.PreviousID(),
}
left.next, right.prev = right, left
return &RangeTraverser{
chain: right,
seekBounds: &rangeBounds{
left: rngSeek.GetOffset(),
right: rngSeek.GetOffset() + rngSeek.GetLength(),
},
}
}
func (c *RangeTraverser) Next() (id *objectSDK.ID, rng *objectSDK.Range) {
left := c.chain.bounds.left
seekLeft := c.seekBounds.left
if left > seekLeft {
id = c.chain.prev.id
} else {
id = c.chain.id
rng = objectSDK.NewRange()
rng.SetOffset(seekLeft - left)
rng.SetLength(min(c.chain.bounds.right, c.seekBounds.right) - seekLeft)
}
return
}
func min(a, b uint64) uint64 {
if a < b {
return a
}
return b
}
func (c *RangeTraverser) PushHeader(obj *object.Object) {
id := obj.ID()
if !id.Equal(c.chain.prev.id) {
panic(fmt.Sprintf("(%T) unexpected identifier in header", c))
}
sz := obj.PayloadSize()
c.chain.prev.bounds = &rangeBounds{
left: c.chain.bounds.left - sz,
right: c.chain.bounds.left,
}
c.chain = c.chain.prev
if prev := obj.PreviousID(); prev != nil {
c.chain.prev = &rangeChain{
next: c.chain,
id: prev,
}
}
}
func (c *RangeTraverser) PushSuccessSize(sz uint64) {
c.seekBounds.left += sz
if c.seekBounds.left >= c.chain.bounds.right && c.chain.next != nil {
c.chain = c.chain.next
}
}
// SetSeekRange moves the chain to the specified range.
// The range is expected to be within the filled chain.
func (c *RangeTraverser) SetSeekRange(r *objectSDK.Range) {
ln, off := r.GetLength(), r.GetOffset()
for {
if off < c.chain.bounds.left {
if c.chain.prev == nil {
break
}
c.chain = c.chain.prev
} else if off >= c.chain.bounds.left && off < c.chain.bounds.right {
break
} else if off >= c.chain.bounds.right {
if c.chain.next == nil {
break
}
c.chain = c.chain.next
}
}
if c.seekBounds == nil {
c.seekBounds = new(rangeBounds)
}
c.seekBounds.left, c.seekBounds.right = off, off+ln
}

View file

@ -135,14 +135,3 @@ func stringifyID(addr *object.ID) string {
func stringifyCID(addr *container.ID) string {
return base58.Encode(addr.ToV2().GetValue())
}
// DeleteObjects adds list of adresses to delete queue.
func (gc *GC) DeleteObjects(list ...*object.Address) {
for i := range list {
select {
case gc.queue <- list[i]:
default:
gc.log.Info("queue for deletion is full")
}
}
}

View file

@ -25,16 +25,6 @@ func testNode(v uint32) (n netmap.NodeInfo) {
return n
}
func flattenVectors(vs []netmap.Nodes) netmap.Nodes {
v := make(netmap.Nodes, 0)
for i := range vs {
v = append(v, vs[i]...)
}
return v
}
func copyVectors(v []netmap.Nodes) []netmap.Nodes {
vc := make([]netmap.Nodes, 0, len(v))