From 2f4d90025fc9298039c5dcd42c7aa9e0926d5f70 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 12 Jan 2021 17:42:00 +0300 Subject: [PATCH] [#234] core/netmap: Extend Source interface Add GetNetMapByEpoch method. Add Epoch method. Signed-off-by: Leonard Lyubich --- pkg/core/netmap/storage.go | 15 +++++++++++++++ pkg/services/object_manager/placement/netmap.go | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/core/netmap/storage.go b/pkg/core/netmap/storage.go index e06af189..df980db8 100644 --- a/pkg/core/netmap/storage.go +++ b/pkg/core/netmap/storage.go @@ -17,6 +17,21 @@ type Source interface { // Implementations must not retain the network map pointer and modify // the network map through it. GetNetMap(diff uint64) (*netmap.Netmap, error) + + // GetNetMapByEpoch reads network map by the epoch number from the storage. + // It returns the pointer to requested network map and any error encountered. + // + // Must return exactly one non-nil value. + // + // Implementations must not retain the network map pointer and modify + // the network map through it. + GetNetMapByEpoch(epoch uint64) (*netmap.Netmap, error) + + // Epoch reads current epoch from the storage. + // It returns number of the current epoch and any error encountered. + // + // Must return exactly one non-default value. + Epoch() (uint64, error) } // GetLatestNetworkMap requests and returns latest network map from storage. diff --git a/pkg/services/object_manager/placement/netmap.go b/pkg/services/object_manager/placement/netmap.go index f5d3d30e..c8272568 100644 --- a/pkg/services/object_manager/placement/netmap.go +++ b/pkg/services/object_manager/placement/netmap.go @@ -12,12 +12,14 @@ type netMapBuilder struct { } type netMapSrc struct { + netmap.Source + nm *netmapSDK.Netmap } func NewNetworkMapBuilder(nm *netmapSDK.Netmap) Builder { return &netMapBuilder{ - nmSrc: &netMapSrc{nm}, + nmSrc: &netMapSrc{nm: nm}, } }