2021-11-09 08:07:49 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import "github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
|
|
|
|
|
|
// ResponseMetaInfo groups meta information about any NeoFS API response.
|
|
|
|
type ResponseMetaInfo struct {
|
|
|
|
key []byte
|
|
|
|
}
|
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
type responseV2 interface {
|
|
|
|
GetMetaHeader() *session.ResponseMetaHeader
|
2021-11-09 08:07:49 +00:00
|
|
|
GetVerificationHeader() *session.ResponseVerificationHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResponderKey returns responder's public key in a binary format.
|
|
|
|
//
|
|
|
|
// Result must not be mutated.
|
|
|
|
func (x ResponseMetaInfo) ResponderKey() []byte {
|
|
|
|
return x.key
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithResponseInfoHandler allows to specify handler of response meta information for the all Client operations.
|
|
|
|
// The handler is called right after the response is received. Client returns handler's error immediately.
|
|
|
|
func WithResponseInfoHandler(f func(ResponseMetaInfo) error) Option {
|
|
|
|
return func(opts *clientOptions) {
|
|
|
|
opts.cbRespInfo = f
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-16 18:17:25 +00:00
|
|
|
func (c *clientImpl) handleResponseInfoV2(opts *callOptions, resp responseV2) error {
|
2021-11-09 08:07:49 +00:00
|
|
|
if c.opts.cbRespInfo == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.opts.cbRespInfo(ResponseMetaInfo{
|
|
|
|
key: resp.GetVerificationHeader().GetBodySignature().GetKey(),
|
|
|
|
})
|
|
|
|
}
|