[#570] *: Use new Equal method of owner.ID type

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 13:30:59 +03:00 committed by Leonard Lyubich
parent 49a42b1d3e
commit 70a7354e9d
4 changed files with 7 additions and 12 deletions

View file

@ -115,9 +115,8 @@ func (v *FormatValidator) checkOwnerKey(id *owner.ID, key []byte) error {
id2 := owner.NewID()
id2.SetNeo3Wallet(wallet)
// FIXME: implement Equal method
if s1, s2 := id.String(), id2.String(); s1 != s2 {
return fmt.Errorf("(%T) different owner identifiers %s/%s", v, s1, s2)
if !id.Equal(id2) {
return fmt.Errorf("(%T) different owner identifiers %s/%s", v, id, id2)
}
return nil

View file

@ -23,11 +23,12 @@ func NewTransferTable() *TransferTable {
}
func (t *TransferTable) Transfer(tx *TransferTx) {
from, to := tx.From.String(), tx.To.String()
if from == to {
if tx.From.Equal(tx.To) {
return
}
from, to := tx.From.String(), tx.To.String()
m, ok := t.txs[from]
if !ok {
if m, ok = t.txs[to]; ok {

View file

@ -1,7 +1,6 @@
package acl
import (
"bytes"
"context"
"crypto/ecdsa"
"errors"
@ -765,11 +764,7 @@ func isOwnerFromKey(id *owner.ID, key *ecdsa.PublicKey) bool {
return false
}
// here we compare `owner.ID -> wallet` with `wallet <- publicKey`
// consider making equal method on owner.ID structure
// we can compare .String() version of owners but don't think it is good idea
// binary comparison is better but MarshalBinary is more expensive
return bytes.Equal(id.ToV2().GetValue(), wallet.Bytes())
return id.Equal(owner.NewIDFromNeo3Wallet(wallet))
}
// originalBearerToken goes down to original request meta header and fetches

View file

@ -65,7 +65,7 @@ func (c SenderClassifier) Classify(
// todo: get owner from neofs.id if present
// if request owner is the same as container owner, return RoleUser
if bytes.Equal(cnr.OwnerID().ToV2().GetValue(), ownerID.ToV2().GetValue()) {
if ownerID.Equal(cnr.OwnerID()) {
return acl.RoleUser, false, ownerKeyInBytes, nil
}