forked from TrueCloudLab/frostfs-api-go
[#259] netmap: Define NetworkInfo RPC and all related messages
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
786462c2a2
commit
d0d2f8d5db
3 changed files with 240 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type Service interface {
|
||||
LocalNodeInfo(ctx context.Context, request *LocalNodeInfoRequest) (*LocalNodeInfoResponse, error)
|
||||
NetworkInfo(ctx context.Context, request *NetworkInfoRequest) (*NetworkInfoResponse, error)
|
||||
}
|
||||
|
||||
type LocalNodeInfoRequest struct {
|
||||
|
@ -25,3 +26,21 @@ type LocalNodeInfoResponse struct {
|
|||
|
||||
verifyHeader *session.ResponseVerificationHeader
|
||||
}
|
||||
|
||||
// NetworkInfoRequest is a structure of NetworkInfo request.
|
||||
type NetworkInfoRequest struct {
|
||||
body *NetworkInfoRequestBody
|
||||
|
||||
metaHeader *session.RequestMetaHeader
|
||||
|
||||
verifyHeader *session.RequestVerificationHeader
|
||||
}
|
||||
|
||||
// NetworkInfoResponse is a structure of NetworkInfo response.
|
||||
type NetworkInfoResponse struct {
|
||||
body *NetworkInfoResponseBody
|
||||
|
||||
metaHeader *session.ResponseMetaHeader
|
||||
|
||||
verifyHeader *session.ResponseVerificationHeader
|
||||
}
|
||||
|
|
|
@ -507,3 +507,143 @@ func (l *LocalNodeInfoResponse) SetVerificationHeader(verifyHeader *session.Resp
|
|||
l.verifyHeader = verifyHeader
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkInfo groups information about
|
||||
// NeoFS network.
|
||||
type NetworkInfo struct {
|
||||
curEpoch, magicNum uint64
|
||||
}
|
||||
|
||||
// GetCurrentEpoch returns number of the current epoch.
|
||||
func (i *NetworkInfo) GetCurrentEpoch() uint64 {
|
||||
if i != nil {
|
||||
return i.curEpoch
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetCurrentEpoch sets number of the current epoch.
|
||||
func (i *NetworkInfo) SetCurrentEpoch(epoch uint64) {
|
||||
if i != nil {
|
||||
i.curEpoch = epoch
|
||||
}
|
||||
}
|
||||
|
||||
// GetMagicNumber returns magic number of the sidechain.
|
||||
func (i *NetworkInfo) GetMagicNumber() uint64 {
|
||||
if i != nil {
|
||||
return i.magicNum
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetMagicNumber sets magic number of the sidechain.
|
||||
func (i *NetworkInfo) SetMagicNumber(magic uint64) {
|
||||
if i != nil {
|
||||
i.magicNum = magic
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkInfoRequestBody is a structure of NetworkInfo request body.
|
||||
type NetworkInfoRequestBody struct{}
|
||||
|
||||
// NetworkInfoResponseBody is a structure of NetworkInfo response body.
|
||||
type NetworkInfoResponseBody struct {
|
||||
netInfo *NetworkInfo
|
||||
}
|
||||
|
||||
// GetNetworkInfo returns information about the NeoFS network.
|
||||
func (i *NetworkInfoResponseBody) GetNetworkInfo() *NetworkInfo {
|
||||
if i != nil {
|
||||
return i.netInfo
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetNetworkInfo sets information about the NeoFS network.
|
||||
func (i *NetworkInfoResponseBody) SetNetworkInfo(netInfo *NetworkInfo) {
|
||||
if i != nil {
|
||||
i.netInfo = netInfo
|
||||
}
|
||||
}
|
||||
|
||||
func (l *NetworkInfoRequest) GetBody() *NetworkInfoRequestBody {
|
||||
if l != nil {
|
||||
return l.body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *NetworkInfoRequest) SetBody(body *NetworkInfoRequestBody) {
|
||||
if l != nil {
|
||||
l.body = body
|
||||
}
|
||||
}
|
||||
|
||||
func (l *NetworkInfoRequest) GetMetaHeader() *session.RequestMetaHeader {
|
||||
if l != nil {
|
||||
return l.metaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *NetworkInfoRequest) SetMetaHeader(metaHeader *session.RequestMetaHeader) {
|
||||
if l != nil {
|
||||
l.metaHeader = metaHeader
|
||||
}
|
||||
}
|
||||
|
||||
func (l *NetworkInfoRequest) GetVerificationHeader() *session.RequestVerificationHeader {
|
||||
if l != nil {
|
||||
return l.verifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *NetworkInfoRequest) SetVerificationHeader(verifyHeader *session.RequestVerificationHeader) {
|
||||
if l != nil {
|
||||
l.verifyHeader = verifyHeader
|
||||
}
|
||||
}
|
||||
|
||||
func (l *NetworkInfoResponse) GetBody() *NetworkInfoResponseBody {
|
||||
if l != nil {
|
||||
return l.body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *NetworkInfoResponse) SetBody(body *NetworkInfoResponseBody) {
|
||||
if l != nil {
|
||||
l.body = body
|
||||
}
|
||||
}
|
||||
|
||||
func (l *NetworkInfoResponse) GetMetaHeader() *session.ResponseMetaHeader {
|
||||
if l != nil {
|
||||
return l.metaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *NetworkInfoResponse) SetMetaHeader(metaHeader *session.ResponseMetaHeader) {
|
||||
if l != nil {
|
||||
l.metaHeader = metaHeader
|
||||
}
|
||||
}
|
||||
|
||||
func (l *NetworkInfoResponse) GetVerificationHeader() *session.ResponseVerificationHeader {
|
||||
if l != nil {
|
||||
return l.verifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *NetworkInfoResponse) SetVerificationHeader(verifyHeader *session.ResponseVerificationHeader) {
|
||||
if l != nil {
|
||||
l.verifyHeader = verifyHeader
|
||||
}
|
||||
}
|
||||
|
|
81
v2/session/util.go
Normal file
81
v2/session/util.go
Normal file
|
@ -0,0 +1,81 @@
|
|||
package session
|
||||
|
||||
// RequestHeaders represents common part of
|
||||
// all NeoFS requests including headers.
|
||||
type RequestHeaders struct {
|
||||
metaHeader *RequestMetaHeader
|
||||
|
||||
verifyHeader *RequestVerificationHeader
|
||||
}
|
||||
|
||||
// GetMetaHeader returns meta header of the request.
|
||||
func (c *RequestHeaders) GetMetaHeader() *RequestMetaHeader {
|
||||
if c != nil {
|
||||
return c.metaHeader
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the request.
|
||||
func (c *RequestHeaders) SetMetaHeader(v *RequestMetaHeader) {
|
||||
if c != nil {
|
||||
c.metaHeader = v
|
||||
}
|
||||
}
|
||||
|
||||
// GetVerificationHeader returns verification header of the request.
|
||||
func (c *RequestHeaders) GetVerificationHeader() *RequestVerificationHeader {
|
||||
if c != nil {
|
||||
return c.verifyHeader
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetVerificationHeader sets verification header of the request.
|
||||
func (c *RequestHeaders) SetVerificationHeader(v *RequestVerificationHeader) {
|
||||
if c != nil {
|
||||
c.verifyHeader = v
|
||||
}
|
||||
}
|
||||
|
||||
// ResponseHeaders represents common part of
|
||||
// all NeoFS responses including headers.
|
||||
type ResponseHeaders struct {
|
||||
metaHeader *ResponseMetaHeader
|
||||
|
||||
verifyHeader *ResponseVerificationHeader
|
||||
}
|
||||
|
||||
// GetMetaHeader returns meta header of the response.
|
||||
func (c *ResponseHeaders) GetMetaHeader() *ResponseMetaHeader {
|
||||
if c != nil {
|
||||
return c.metaHeader
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the response.
|
||||
func (c *ResponseHeaders) SetMetaHeader(v *ResponseMetaHeader) {
|
||||
if c != nil {
|
||||
c.metaHeader = v
|
||||
}
|
||||
}
|
||||
|
||||
// GetVerificationHeader returns verification header of the response.
|
||||
func (c *ResponseHeaders) GetVerificationHeader() *ResponseVerificationHeader {
|
||||
if c != nil {
|
||||
return c.verifyHeader
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetVerificationHeader sets verification header of the response.
|
||||
func (c *ResponseHeaders) SetVerificationHeader(v *ResponseVerificationHeader) {
|
||||
if c != nil {
|
||||
c.verifyHeader = v
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue