From 7fdb14cf8ac990c94780b988c6c23e74e2b374d5 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 22 Oct 2020 14:22:23 +0300 Subject: [PATCH] [#83] services/response: Set epoch number from network state Signed-off-by: Leonard Lyubich --- pkg/services/util/response/service.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/services/util/response/service.go b/pkg/services/util/response/service.go index 29e91e3ec..5cdeb84ed 100644 --- a/pkg/services/util/response/service.go +++ b/pkg/services/util/response/service.go @@ -4,6 +4,7 @@ import ( "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/nspcc-dev/neofs-api-go/v2/session" + "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/services/util" ) @@ -19,7 +20,7 @@ type Option func(*cfg) type cfg struct { version *refs.Version - // TODO: neofs-node#83 add network state + state netmap.State } func defaultCfg() *cfg { @@ -45,9 +46,7 @@ func setMeta(resp util.ResponseMessage, cfg *cfg) { meta := new(session.ResponseMetaHeader) meta.SetVersion(cfg.version) meta.SetTTL(1) // FIXME: TTL must be calculated - - // TODO: neofs-node#83 - // meta.SetEpoch() + meta.SetEpoch(cfg.state.CurrentEpoch()) if origin := resp.GetMetaHeader(); origin != nil { // FIXME: what if origin is set by local server? @@ -56,3 +55,10 @@ func setMeta(resp util.ResponseMessage, cfg *cfg) { resp.SetMetaHeader(meta) } + +// WithNetworkState returns option to set network state of Service. +func WithNetworkState(v netmap.State) Option { + return func(c *cfg) { + c.state = v + } +}