[#570] *: Use new Equal method of owner.ID type
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
49a42b1d3e
commit
70a7354e9d
4 changed files with 7 additions and 12 deletions
|
@ -115,9 +115,8 @@ func (v *FormatValidator) checkOwnerKey(id *owner.ID, key []byte) error {
|
||||||
id2 := owner.NewID()
|
id2 := owner.NewID()
|
||||||
id2.SetNeo3Wallet(wallet)
|
id2.SetNeo3Wallet(wallet)
|
||||||
|
|
||||||
// FIXME: implement Equal method
|
if !id.Equal(id2) {
|
||||||
if s1, s2 := id.String(), id2.String(); s1 != s2 {
|
return fmt.Errorf("(%T) different owner identifiers %s/%s", v, id, id2)
|
||||||
return fmt.Errorf("(%T) different owner identifiers %s/%s", v, s1, s2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -23,11 +23,12 @@ func NewTransferTable() *TransferTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TransferTable) Transfer(tx *TransferTx) {
|
func (t *TransferTable) Transfer(tx *TransferTx) {
|
||||||
from, to := tx.From.String(), tx.To.String()
|
if tx.From.Equal(tx.To) {
|
||||||
if from == to {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
from, to := tx.From.String(), tx.To.String()
|
||||||
|
|
||||||
m, ok := t.txs[from]
|
m, ok := t.txs[from]
|
||||||
if !ok {
|
if !ok {
|
||||||
if m, ok = t.txs[to]; ok {
|
if m, ok = t.txs[to]; ok {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package acl
|
package acl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"errors"
|
"errors"
|
||||||
|
@ -765,11 +764,7 @@ func isOwnerFromKey(id *owner.ID, key *ecdsa.PublicKey) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// here we compare `owner.ID -> wallet` with `wallet <- publicKey`
|
return id.Equal(owner.NewIDFromNeo3Wallet(wallet))
|
||||||
// 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())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// originalBearerToken goes down to original request meta header and fetches
|
// originalBearerToken goes down to original request meta header and fetches
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (c SenderClassifier) Classify(
|
||||||
// todo: get owner from neofs.id if present
|
// todo: get owner from neofs.id if present
|
||||||
|
|
||||||
// if request owner is the same as container owner, return RoleUser
|
// 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
|
return acl.RoleUser, false, ownerKeyInBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue