diff --git a/pkg/services/audit/auditor/context.go b/pkg/services/audit/auditor/context.go index 4097537ae..f0ebbf1b8 100644 --- a/pkg/services/audit/auditor/context.go +++ b/pkg/services/audit/auditor/context.go @@ -34,6 +34,8 @@ type Context struct { } cnrNodesNum int + + headResponses map[string]shortHeader } type pairMemberInfo struct { @@ -48,6 +50,12 @@ type gamePair struct { id *object.ID } +type shortHeader struct { + tzhash []byte + + objectSize uint64 +} + // ContextPrm groups components required to conduct data audit checks. type ContextPrm struct { log *logger.Logger @@ -114,6 +122,8 @@ func (c *Context) init() { c.pairedNodes = make(map[uint64]pairMemberInfo) + c.headResponses = make(map[string]shortHeader) + c.log = c.log.With( zap.Stringer("container ID", c.task.ContainerID()), ) @@ -166,3 +176,34 @@ func (c *Context) buildPlacement(id *object.ID) ([]netmap.Nodes, error) { return nn, nil } + +func (c *Context) objectSize(id *object.ID) uint64 { + strID := id.String() + + if hdr, ok := c.headResponses[strID]; ok { + return hdr.objectSize + } + + return 0 +} + +func (c *Context) objectHomoHash(id *object.ID) []byte { + strID := id.String() + + if hdr, ok := c.headResponses[strID]; ok { + return hdr.tzhash + } + + return nil +} + +func (c *Context) updateHeadResponses(hdr *object.Object) { + strID := hdr.ID().String() + + if _, ok := c.headResponses[strID]; !ok { + c.headResponses[strID] = shortHeader{ + tzhash: hdr.PayloadHomomorphicHash().Sum(), + objectSize: hdr.PayloadSize(), + } + } +} diff --git a/pkg/services/audit/auditor/por.go b/pkg/services/audit/auditor/por.go index acd9a0643..82ade8e63 100644 --- a/pkg/services/audit/auditor/por.go +++ b/pkg/services/audit/auditor/por.go @@ -54,6 +54,9 @@ func (c *Context) checkStorageGroupPoR(ind int, sg *object.ID) { continue } + // update cache for PoR and PDP audit checks + c.updateHeadResponses(hdr) + if len(tzHash) == 0 { tzHash = hdr.PayloadHomomorphicHash().Sum() } else {