[#1115] shard/gc: provide parsed addresses in HandleExpiredTombstones
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
7ca06aeae2
commit
c1530dec5e
4 changed files with 8 additions and 22 deletions
|
@ -135,10 +135,10 @@ func (e *StorageEngine) inhumeAddr(addr *addressSDK.Address, prm *shard.InhumePr
|
|||
}
|
||||
|
||||
func (e *StorageEngine) processExpiredTombstones(ctx context.Context, addrs []*addressSDK.Address) {
|
||||
tss := make(map[string]struct{}, len(addrs))
|
||||
tss := make(map[string]*addressSDK.Address, len(addrs))
|
||||
|
||||
for i := range addrs {
|
||||
tss[addrs[i].String()] = struct{}{}
|
||||
tss[addrs[i].String()] = addrs[i]
|
||||
}
|
||||
|
||||
e.iterateOverUnsortedShards(func(sh hashedShard) (stop bool) {
|
||||
|
|
|
@ -120,13 +120,13 @@ func objectType(tx *bbolt.Tx, cid *cid.ID, oidBytes []byte) object.Type {
|
|||
// Returns other errors of h directly.
|
||||
//
|
||||
// Does not modify tss.
|
||||
func (db *DB) IterateCoveredByTombstones(tss map[string]struct{}, h func(*addressSDK.Address) error) error {
|
||||
func (db *DB) IterateCoveredByTombstones(tss map[string]*addressSDK.Address, h func(*addressSDK.Address) error) error {
|
||||
return db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
return db.iterateCoveredByTombstones(tx, tss, h)
|
||||
})
|
||||
}
|
||||
|
||||
func (db *DB) iterateCoveredByTombstones(tx *bbolt.Tx, tss map[string]struct{}, h func(*addressSDK.Address) error) error {
|
||||
func (db *DB) iterateCoveredByTombstones(tx *bbolt.Tx, tss map[string]*addressSDK.Address, h func(*addressSDK.Address) error) error {
|
||||
bktGraveyard := tx.Bucket(graveyardBucketName)
|
||||
if bktGraveyard == nil {
|
||||
return nil
|
||||
|
|
|
@ -82,8 +82,8 @@ func TestDB_IterateCoveredByTombstones(t *testing.T) {
|
|||
|
||||
var handled []*addressSDK.Address
|
||||
|
||||
tss := map[string]struct{}{
|
||||
ts.String(): {},
|
||||
tss := map[string]*addressSDK.Address{
|
||||
ts.String(): ts,
|
||||
}
|
||||
|
||||
err = db.IterateCoveredByTombstones(tss, func(addr *addressSDK.Address) error {
|
||||
|
|
|
@ -276,7 +276,7 @@ func (s *Shard) getExpiredObjects(ctx context.Context, epoch uint64, collectTomb
|
|||
// If successful, marks tombstones themselves as garbage.
|
||||
//
|
||||
// Does not modify tss.
|
||||
func (s *Shard) HandleExpiredTombstones(tss map[string]struct{}) {
|
||||
func (s *Shard) HandleExpiredTombstones(tss map[string]*addressSDK.Address) {
|
||||
inhume := make([]*addressSDK.Address, 0, len(tss))
|
||||
|
||||
// Collect all objects covered by the tombstones.
|
||||
|
@ -317,21 +317,7 @@ func (s *Shard) HandleExpiredTombstones(tss map[string]struct{}) {
|
|||
|
||||
inhume = inhume[:0]
|
||||
|
||||
for strAddr := range tss {
|
||||
// parse address
|
||||
// TODO: make type of map values *object.Address since keys are calculated from addresses
|
||||
addr := addressSDK.NewAddress()
|
||||
|
||||
err = addr.Parse(strAddr)
|
||||
if err != nil {
|
||||
s.log.Error("could not parse tombstone address",
|
||||
zap.String("text", strAddr),
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
continue // try process other tombstones
|
||||
}
|
||||
|
||||
for _, addr := range tss {
|
||||
inhume = append(inhume, addr)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue