2020-09-21 14:24:03 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-sdk-go/netmap"
|
2020-09-21 14:24:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Source is an interface that wraps
|
|
|
|
// basic network map receiving method.
|
|
|
|
type Source interface {
|
|
|
|
// GetNetMap reads the diff-th past network map from the storage.
|
2022-04-21 11:28:05 +00:00
|
|
|
// Calling with zero diff returns the latest network map.
|
|
|
|
// It returns the pointer to the requested network map and any error encountered.
|
2020-09-21 14:24:03 +00:00
|
|
|
//
|
|
|
|
// GetNetMap must return exactly one non-nil value.
|
2022-04-21 11:28:05 +00:00
|
|
|
// GetNetMap must return ErrNotFound if the network map is not in the storage.
|
2020-09-21 14:24:03 +00:00
|
|
|
//
|
|
|
|
// Implementations must not retain the network map pointer and modify
|
|
|
|
// the network map through it.
|
2022-06-08 23:18:26 +00:00
|
|
|
GetNetMap(diff uint64) (*netmap.NetMap, error)
|
2021-01-12 14:42:00 +00:00
|
|
|
|
|
|
|
// GetNetMapByEpoch reads network map by the epoch number from the storage.
|
2022-04-21 11:28:05 +00:00
|
|
|
// It returns the pointer to the requested network map and any error encountered.
|
2021-01-12 14:42:00 +00:00
|
|
|
//
|
|
|
|
// Must return exactly one non-nil value.
|
|
|
|
//
|
|
|
|
// Implementations must not retain the network map pointer and modify
|
|
|
|
// the network map through it.
|
2022-06-08 23:18:26 +00:00
|
|
|
GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error)
|
2021-01-12 14:42:00 +00:00
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// Epoch reads the current epoch from the storage.
|
|
|
|
// It returns thw number of the current epoch and any error encountered.
|
2021-01-12 14:42:00 +00:00
|
|
|
//
|
|
|
|
// Must return exactly one non-default value.
|
|
|
|
Epoch() (uint64, error)
|
2020-09-21 14:24:03 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// GetLatestNetworkMap requests and returns the latest network map from the storage.
|
2022-06-08 23:18:26 +00:00
|
|
|
func GetLatestNetworkMap(src Source) (*netmap.NetMap, error) {
|
2020-09-21 14:24:03 +00:00
|
|
|
return src.GetNetMap(0)
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// GetPreviousNetworkMap requests and returns previous from the latest network map from the storage.
|
2022-06-08 23:18:26 +00:00
|
|
|
func GetPreviousNetworkMap(src Source) (*netmap.NetMap, error) {
|
2020-09-21 14:24:03 +00:00
|
|
|
return src.GetNetMap(1)
|
|
|
|
}
|