From 69c8e7aea9a5f1d3a9067968ded77d7710c82b11 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 12 Jan 2021 11:09:30 +0300 Subject: [PATCH] [#34] netmap: Add snapshot getter by epoch number There are cases when NeoFS applications need to fetch netmap snapshot of exact epoch. This method provides convenient atomic way to do that. Signed-off-by: Alex Vanin --- netmap/netmap_contract.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/netmap/netmap_contract.go b/netmap/netmap_contract.go index e4c495c..bd29daf 100644 --- a/netmap/netmap_contract.go +++ b/netmap/netmap_contract.go @@ -273,6 +273,12 @@ func Snapshot(diff int) []storageNode { return getSnapshot(ctx, key) } +func SnapshotByEpoch(epoch int) []storageNode { + currentEpoch := storage.Get(ctx, snapshotEpoch).(int) + + return Snapshot(currentEpoch - epoch) +} + func Config(key []byte) interface{} { return getConfig(ctx, key) }