[#236] *: Notify user on success

Add notifications to:
- container put, delete, setEACL
- netmap addPeer, updateState

Because notifications are limited in size (currently arguments should be
less than 1024 bytes) provide only minimal information, such as entity
ID (container ID or node public key).

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-04-01 08:52:54 +03:00 committed by Alex Vanin
parent 0aa7fd4189
commit fd70f28b47
4 changed files with 39 additions and 3 deletions

View file

@ -14,6 +14,12 @@ events:
type: PublicKey
- name: token
type: ByteArray
- name: PutSuccess
parameters:
- name: containerID
type: Hash256
- name: publicKey
type: PublicKey
- name: containerDelete
parameters:
- name: containerID
@ -22,6 +28,10 @@ events:
type: Signature
- name: token
type: ByteArray
- name: DeleteSuccess
parameters:
- name: containerID
type: ByteArray
- name: setEACL
parameters:
- name: eACL
@ -32,6 +42,12 @@ events:
type: PublicKey
- name: token
type: ByteArray
- name: SetEACLSuccess
parameters:
- name: containerID
type: ByteArray
- name: publicKey
type: PublicKey
- name: StartEstimation
parameters:
- name: epoch

View file

@ -276,6 +276,7 @@ func PutNamed(container []byte, signature interop.Signature,
}
runtime.Log("added new container")
runtime.Notify("PutSuccess", containerID, publicKey)
}
// checkNiceNameAvailable checks if nice name is available for the container.
@ -357,6 +358,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) {
}
removeContainer(ctx, containerID, ownerID)
runtime.Log("remove container")
runtime.Notify("DeleteSuccess", containerID)
}
// Get method returns structure that contains stable marshaled Container structure,
@ -464,6 +466,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
common.SetSerialized(ctx, key, rule)
runtime.Log("success")
runtime.Notify("SetEACLSuccess", containerID, publicKey)
}
// EACL method returns structure that contains stable marshaled EACLTable structure,

View file

@ -7,12 +7,22 @@ events:
parameters:
- name: nodeInfo
type: ByteArray
- name: AddPeerSuccess
parameters:
- name: publicKey
type: PublicKey
- name: UpdateState
parameters:
- name: state
type: Integer
- name: publicKey
type: PublicKey
- name: UpdateStateSuccess
parameters:
- name: publicKey
type: PublicKey
- name: state
type: Integer
- name: NewEpoch
parameters:
- name: epoch

View file

@ -202,6 +202,9 @@ func AddPeerIR(nodeInfo []byte) {
common.CheckAlphabetWitness(common.AlphabetAddress())
addToNetmap(ctx, storageNode{info: nodeInfo})
publicKey := nodeInfo[2:35] // V2 format: offset:2, len:33
runtime.Notify("AddPeerSuccess", interop.PublicKey(publicKey))
}
// AddPeer method adds new candidate to the next network map if it was invoked
@ -225,12 +228,12 @@ func AddPeer(nodeInfo []byte) {
nodeKey = common.InnerRingInvoker(alphabet)
}
// If notary is enabled or caller is not an alphabet node,
// just emit the notification for alphabet.
if !notaryDisabled || len(nodeKey) == 0 {
// V2 format
publicKey := nodeInfo[2:35] // offset:2, len:33
// If notary is enabled or caller is not an alphabet node,
// just emit the notification for alphabet.
if !notaryDisabled || len(nodeKey) == 0 {
common.CheckWitness(publicKey)
if notaryDisabled {
runtime.Notify("AddPeer", nodeInfo)
@ -256,6 +259,7 @@ func AddPeer(nodeInfo []byte) {
}
addToNetmap(ctx, candidate)
runtime.Notify("AddPeerSuccess", interop.PublicKey(publicKey))
}
// UpdateState method updates state of node from the network map candidate list.
@ -316,6 +320,8 @@ func UpdateState(state int, publicKey interop.PublicKey) {
default:
panic("unsupported state")
}
runtime.Notify("UpdateStateSuccess", publicKey, state)
}
// UpdateStateIR method tries to change node state in the network map.
@ -335,6 +341,7 @@ func UpdateStateIR(state nodeState, publicKey interop.PublicKey) {
default:
panic("unsupported state")
}
runtime.Notify("UpdateStateSuccess", publicKey, state)
}
// NewEpoch method changes epoch number up to provided epochNum argument. Can