[#378] shard/gc: Reuse addressFromKey func in all appropriate places

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-19 11:31:25 +03:00 committed by Alex Vanin
parent 72f7df3339
commit a6d5556dc1
3 changed files with 5 additions and 11 deletions

View file

@ -131,9 +131,7 @@ func (db *DB) iterateCoveredByTombstones(tx *bbolt.Tx, tss map[string]struct{},
err := bktGraveyard.ForEach(func(k, v []byte) error {
if _, ok := tss[string(v)]; ok {
addr := object.NewAddress()
err := addr.Parse(string(k))
addr, err := addressFromKey(k)
if err != nil {
return errors.Wrap(err, "could not parse address of the object under tombstone")
}

View file

@ -131,9 +131,7 @@ func (db *DB) Movable(prm *MovablePrm) (*MovableRes, error) {
addrs := make([]*objectSDK.Address, 0, len(strAddrs))
for i := range strAddrs {
addr := objectSDK.NewAddress()
err = addr.Parse(strAddrs[i])
addr, err := addressFromKey([]byte(strAddrs[i]))
if err != nil {
return nil, fmt.Errorf("can't parse object address %v: %w",
strAddrs[i], err)

View file

@ -128,8 +128,8 @@ func (db *DB) selectObjects(tx *bbolt.Tx, cid *container.ID, fs object.SearchFil
continue // ignore objects with unmatched fast filters
}
addr := object.NewAddress()
if err := addr.Parse(a); err != nil {
addr, err := addressFromKey([]byte(a))
if err != nil {
// TODO: storage was broken, so we need to handle it
return nil, err
}
@ -435,9 +435,7 @@ func (db *DB) selectObjectID(
appendOID := func(oid string) {
addrStr := prefix + string(oid)
addr := object.NewAddress()
err := addr.Parse(addrStr)
addr, err := addressFromKey([]byte(addrStr))
if err != nil {
db.log.Debug("can't decode object id address",
zap.String("addr", addrStr),