From f1a4b8d3226ab07739956dd7bd0f9281e1c355e7 Mon Sep 17 00:00:00 2001
From: Leonard Lyubich <leonard@nspcc.ru>
Date: Fri, 19 Feb 2021 18:23:21 +0300
Subject: [PATCH] [#217] cmd/node: Use local Inhume operation as a redundant
 copy callback

Exec `StorageEngine.Inhume` operation on redundant copy callback from Object
Policer with `MarkAsGarbage` parameter.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
---
 cmd/neofs-node/object.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go
index ea4f578ada..e79ed874c6 100644
--- a/cmd/neofs-node/object.go
+++ b/cmd/neofs-node/object.go
@@ -202,6 +202,14 @@ func initObjectService(c *cfg) {
 			c.viper.GetDuration(cfgPolicerHeadTimeout),
 		),
 		policer.WithReplicator(repl),
+		policer.WithRedundantCopyCallback(func(addr *objectSDK.Address) {
+			_, err := ls.Inhume(new(engine.InhumePrm).MarkAsGarbage(addr))
+			if err != nil {
+				c.log.Warn("could not inhume mark redundant copy as garbage",
+					zap.String("error", err.Error()),
+				)
+			}
+		}),
 	)
 
 	addNewEpochNotificationHandler(c, func(ev event.Event) {