Some checks failed
DCO action / DCO (pull_request) Successful in 59s
Vulncheck / Vulncheck (pull_request) Successful in 1m4s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m55s
Build / Build Components (pull_request) Successful in 2m4s
Tests and linters / Staticcheck (pull_request) Successful in 2m38s
Tests and linters / Lint (pull_request) Successful in 3m16s
Tests and linters / Run gofumpt (pull_request) Successful in 3m54s
Tests and linters / Tests (pull_request) Successful in 4m12s
Tests and linters / gopls check (pull_request) Successful in 4m31s
Tests and linters / Tests with -race (pull_request) Successful in 4m38s
OCI image / Build container images (push) Failing after 18s
Vulncheck / Vulncheck (push) Successful in 1m2s
Pre-commit hooks / Pre-commit (push) Successful in 1m39s
Build / Build Components (push) Successful in 1m45s
Tests and linters / Staticcheck (push) Successful in 2m18s
Tests and linters / Run gofumpt (push) Successful in 2m46s
Tests and linters / Lint (push) Successful in 3m5s
Tests and linters / Tests with -race (push) Successful in 3m23s
Tests and linters / Tests (push) Successful in 3m52s
Tests and linters / gopls check (push) Successful in 4m18s
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
47 lines
1.7 KiB
Go
47 lines
1.7 KiB
Go
package netmap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
|
)
|
|
|
|
// 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.
|
|
// Calling with zero diff returns the latest network map.
|
|
// It returns the pointer to the requested network map and any error encountered.
|
|
//
|
|
// GetNetMap must return exactly one non-nil value.
|
|
// GetNetMap must return ErrNotFound if the network map is not in the storage.
|
|
//
|
|
// Implementations must not retain the network map pointer and modify
|
|
// the network map through it.
|
|
GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error)
|
|
|
|
// GetNetMapByEpoch reads network map by the epoch number from the storage.
|
|
// It returns the pointer to the 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(ctx context.Context, epoch uint64) (*netmap.NetMap, error)
|
|
|
|
// Epoch reads the current epoch from the storage.
|
|
// It returns thw number of the current epoch and any error encountered.
|
|
//
|
|
// Must return exactly one non-default value.
|
|
Epoch(ctx context.Context) (uint64, error)
|
|
}
|
|
|
|
// GetLatestNetworkMap requests and returns the latest network map from the storage.
|
|
func GetLatestNetworkMap(ctx context.Context, src Source) (*netmap.NetMap, error) {
|
|
return src.GetNetMap(ctx, 0)
|
|
}
|
|
|
|
// GetPreviousNetworkMap requests and returns previous from the latest network map from the storage.
|
|
func GetPreviousNetworkMap(ctx context.Context, src Source) (*netmap.NetMap, error) {
|
|
return src.GetNetMap(ctx, 1)
|
|
}
|