forked from TrueCloudLab/frostfs-node
[#234] core/netmap: Extend Source interface
Add GetNetMapByEpoch method. Add Epoch method. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
1d56e60589
commit
2f4d90025f
2 changed files with 18 additions and 1 deletions
|
@ -17,6 +17,21 @@ type Source interface {
|
||||||
// Implementations must not retain the network map pointer and modify
|
// Implementations must not retain the network map pointer and modify
|
||||||
// the network map through it.
|
// the network map through it.
|
||||||
GetNetMap(diff uint64) (*netmap.Netmap, error)
|
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.
|
// GetLatestNetworkMap requests and returns latest network map from storage.
|
||||||
|
|
|
@ -12,12 +12,14 @@ type netMapBuilder struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type netMapSrc struct {
|
type netMapSrc struct {
|
||||||
|
netmap.Source
|
||||||
|
|
||||||
nm *netmapSDK.Netmap
|
nm *netmapSDK.Netmap
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNetworkMapBuilder(nm *netmapSDK.Netmap) Builder {
|
func NewNetworkMapBuilder(nm *netmapSDK.Netmap) Builder {
|
||||||
return &netMapBuilder{
|
return &netMapBuilder{
|
||||||
nmSrc: &netMapSrc{nm},
|
nmSrc: &netMapSrc{nm: nm},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue