@@ -11,8 +11,11 @@ import (
11
11
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
12
12
cntClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
13
13
"github.com/nspcc-dev/neofs-node/pkg/services/meta"
14
+ getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
14
15
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
15
16
netmapsdk "github.com/nspcc-dev/neofs-sdk-go/netmap"
17
+ "github.com/nspcc-dev/neofs-sdk-go/object"
18
+ oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
16
19
"go.uber.org/zap"
17
20
"golang.org/x/sync/errgroup"
18
21
)
@@ -22,22 +25,23 @@ func initMeta(c *cfg) {
22
25
initMorphComponents (c )
23
26
}
24
27
25
- c .cfgMeta .cLister = & metaContainerListener {
28
+ c .cfgMeta .network = & neofsNetwork {
26
29
key : c .binPublicKey ,
27
30
cnrClient : c .basics .cCli ,
28
31
containers : c .cfgObject .cnrSource ,
29
32
network : c .basics .netMapSource ,
33
+ header : c .cfgObject .getSvc ,
30
34
}
31
35
32
36
var err error
33
37
p := meta.Parameters {
34
- Logger : c .log .With (zap .String ("service" , "meta data" )),
35
- ContainerLister : c .cfgMeta .cLister ,
36
- Timeout : c .applicationConfiguration .fsChain .dialTimeout ,
37
- NeoEnpoints : c .applicationConfiguration .fsChain .endpoints ,
38
- ContainerHash : c .basics .containerSH ,
39
- NetmapHash : c .basics .netmapSH ,
40
- RootPath : c .applicationConfiguration .metadata .path ,
38
+ Logger : c .log .With (zap .String ("service" , "meta data" )),
39
+ Network : c .cfgMeta .network ,
40
+ Timeout : c .applicationConfiguration .fsChain .dialTimeout ,
41
+ NeoEnpoints : c .applicationConfiguration .fsChain .endpoints ,
42
+ ContainerHash : c .basics .containerSH ,
43
+ NetmapHash : c .basics .netmapSH ,
44
+ RootPath : c .applicationConfiguration .metadata .path ,
41
45
}
42
46
c .shared .metaService , err = meta .New (p )
43
47
fatalOnErr (err )
@@ -50,20 +54,36 @@ func initMeta(c *cfg) {
50
54
}))
51
55
}
52
56
53
- type metaContainerListener struct {
57
+ type neofsNetwork struct {
54
58
key []byte
55
59
56
60
cnrClient * cntClient.Client
57
61
containers container.Source
58
62
network netmap.Source
63
+ header * getsvc.Service
59
64
60
65
m sync.RWMutex
61
66
prevCnrs []cid.ID
62
67
prevNetMap * netmapsdk.NetMap
63
68
prevRes map [cid.ID ]struct {}
64
69
}
65
70
66
- func (c * metaContainerListener ) IsMineWithMeta (id cid.ID ) (bool , error ) {
71
+ func (c * neofsNetwork ) Head (ctx context.Context , cID cid.ID , oID oid.ID ) (object.Object , error ) {
72
+ var hw headerWriter
73
+ var addr oid.Address
74
+ addr .SetContainer (cID )
75
+ addr .SetObject (oID )
76
+
77
+ var hPrm getsvc.HeadPrm
78
+ hPrm .SetHeaderWriter (& hw )
79
+ hPrm .WithAddress (addr )
80
+
81
+ err := c .header .Head (ctx , hPrm )
82
+
83
+ return * hw .h , err
84
+ }
85
+
86
+ func (c * neofsNetwork ) IsMineWithMeta (id cid.ID ) (bool , error ) {
67
87
curEpoch , err := c .network .Epoch ()
68
88
if err != nil {
69
89
return false , fmt .Errorf ("read current NeoFS epoch: %w" , err )
@@ -75,7 +95,7 @@ func (c *metaContainerListener) IsMineWithMeta(id cid.ID) (bool, error) {
75
95
return c .isMineWithMeta (id , networkMap )
76
96
}
77
97
78
- func (c * metaContainerListener ) isMineWithMeta (id cid.ID , networkMap * netmapsdk.NetMap ) (bool , error ) {
98
+ func (c * neofsNetwork ) isMineWithMeta (id cid.ID , networkMap * netmapsdk.NetMap ) (bool , error ) {
79
99
cnr , err := c .containers .Get (id )
80
100
if err != nil {
81
101
return false , fmt .Errorf ("read %s container: %w" , id , err )
@@ -104,7 +124,7 @@ func (c *metaContainerListener) isMineWithMeta(id cid.ID, networkMap *netmapsdk.
104
124
return false , nil
105
125
}
106
126
107
- func (c * metaContainerListener ) List () (map [cid.ID ]struct {}, error ) {
127
+ func (c * neofsNetwork ) List () (map [cid.ID ]struct {}, error ) {
108
128
actualContainers , err := c .cnrClient .List (nil )
109
129
if err != nil {
110
130
return nil , fmt .Errorf ("read containers: %w" , err )
0 commit comments