Skip to content

Commit

Permalink
*: drop subnet support
Browse files Browse the repository at this point in the history
We don't need them and while there are reason to have some remnants in the
protocol itself we can remove them from the SDK immediately to not include
them into the 1.0.0 release.

Refs. nspcc-dev/neofs-api#261.
  • Loading branch information
roman-khimov committed May 22, 2023
1 parent 7002b3b commit ee39ca7
Show file tree
Hide file tree
Showing 18 changed files with 2 additions and 994 deletions.
25 changes: 0 additions & 25 deletions container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
"github.com/nspcc-dev/neofs-sdk-go/netmap"
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
"github.com/nspcc-dev/neofs-sdk-go/user"
"github.com/nspcc-dev/neofs-sdk-go/version"
)
Expand Down Expand Up @@ -116,8 +115,6 @@ func (x *Container) readFromV2(m container.Container, checkFieldPresence bool) e
}

switch key {
case container.SysAttributeSubnet:
err = new(subnetid.ID).DecodeString(val)
case attributeTimestamp:
_, err = strconv.ParseInt(val, 10, 64)
}
Expand Down Expand Up @@ -381,28 +378,6 @@ func CreatedAt(cnr Container) time.Time {
return time.Unix(sec, 0)
}

// SetSubnet places the Container on the specified NeoFS subnet. If called,
// container nodes will only be selected from the given subnet, otherwise from
// the entire network.
func SetSubnet(cnr *Container, subNet subnetid.ID) {
cnr.SetAttribute(container.SysAttributeSubnet, subNet.EncodeToString())
}

// Subnet return container subnet set using SetSubnet.
//
// Zero Container is bound to zero subnet.
func Subnet(cnr Container) (res subnetid.ID) {
val := cnr.Attribute(container.SysAttributeSubnet)
if val != "" {
err := res.DecodeString(val)
if err != nil {
panic(fmt.Sprintf("invalid subnet attribute: %s (%v)", val, err))
}
}

return
}

const attributeHomoHashEnabled = "true"

// DisableHomomorphicHashing sets flag to disable homomorphic hashing of the
Expand Down
24 changes: 0 additions & 24 deletions container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
"github.com/nspcc-dev/neofs-sdk-go/crypto/test"
netmaptest "github.com/nspcc-dev/neofs-sdk-go/netmap/test"
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
subnetidtest "github.com/nspcc-dev/neofs-sdk-go/subnet/id/test"
usertest "github.com/nspcc-dev/neofs-sdk-go/user/test"
"github.com/nspcc-dev/neofs-sdk-go/version"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -233,28 +231,6 @@ func TestSetCreationTime(t *testing.T) {
require.Equal(t, creat.Unix(), container.CreatedAt(val2).Unix())
}

func TestSetSubnet(t *testing.T) {
var val container.Container

require.True(t, subnetid.IsZero(container.Subnet(val)))

val = containertest.Container(t)

sub := subnetidtest.ID()

container.SetSubnet(&val, sub)

var msg v2container.Container
val.WriteToV2(&msg)

assertContainsAttribute(t, msg, v2container.SysAttributeSubnet, sub.EncodeToString())

var val2 container.Container
require.NoError(t, val2.ReadFromV2(msg))

require.Equal(t, sub, container.Subnet(val))
}

func TestDisableHomomorphicHashing(t *testing.T) {
var val container.Container

Expand Down
254 changes: 0 additions & 254 deletions netmap/json_tests/subnet.json

This file was deleted.

Loading

0 comments on commit ee39ca7

Please sign in to comment.