forked from TrueCloudLab/frostfs-node
[#525] event/container: Parse binary session token from Put notification
The 4th item of `Put` container notification event is a byte array of serialized session token. Parse session token in `ParsePut` function. Provide `Put.SessionToken` method. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
98cc685a9b
commit
0f91b78df1
2 changed files with 27 additions and 1 deletions
|
@ -13,6 +13,7 @@ type Put struct {
|
|||
rawContainer []byte
|
||||
signature []byte
|
||||
publicKey []byte
|
||||
token []byte
|
||||
}
|
||||
|
||||
const expectedItemNumPut = 4
|
||||
|
@ -29,6 +30,12 @@ func (p Put) Signature() []byte { return p.signature }
|
|||
// PublicKey of container owner.
|
||||
func (p Put) PublicKey() []byte { return p.publicKey }
|
||||
|
||||
// Session token returns binary token of the session
|
||||
// within which the container was created.
|
||||
func (p Put) SessionToken() []byte {
|
||||
return p.token
|
||||
}
|
||||
|
||||
// ParsePut from notification into container event structure.
|
||||
func ParsePut(params []stackitem.Item) (event.Event, error) {
|
||||
var (
|
||||
|
@ -58,5 +65,11 @@ func ParsePut(params []stackitem.Item) (event.Event, error) {
|
|||
return nil, fmt.Errorf("could not get public key: %w", err)
|
||||
}
|
||||
|
||||
// parse session token
|
||||
ev.token, err = client.BytesFromStackItem(params[3])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get sesison token: %w", err)
|
||||
}
|
||||
|
||||
return ev, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue