forked from TrueCloudLab/frostfs-contract
[#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:
parent
0aa7fd4189
commit
fd70f28b47
4 changed files with 39 additions and 3 deletions
|
@ -14,6 +14,12 @@ events:
|
||||||
type: PublicKey
|
type: PublicKey
|
||||||
- name: token
|
- name: token
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
|
- name: PutSuccess
|
||||||
|
parameters:
|
||||||
|
- name: containerID
|
||||||
|
type: Hash256
|
||||||
|
- name: publicKey
|
||||||
|
type: PublicKey
|
||||||
- name: containerDelete
|
- name: containerDelete
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
|
@ -22,6 +28,10 @@ events:
|
||||||
type: Signature
|
type: Signature
|
||||||
- name: token
|
- name: token
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
|
- name: DeleteSuccess
|
||||||
|
parameters:
|
||||||
|
- name: containerID
|
||||||
|
type: ByteArray
|
||||||
- name: setEACL
|
- name: setEACL
|
||||||
parameters:
|
parameters:
|
||||||
- name: eACL
|
- name: eACL
|
||||||
|
@ -32,6 +42,12 @@ events:
|
||||||
type: PublicKey
|
type: PublicKey
|
||||||
- name: token
|
- name: token
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
|
- name: SetEACLSuccess
|
||||||
|
parameters:
|
||||||
|
- name: containerID
|
||||||
|
type: ByteArray
|
||||||
|
- name: publicKey
|
||||||
|
type: PublicKey
|
||||||
- name: StartEstimation
|
- name: StartEstimation
|
||||||
parameters:
|
parameters:
|
||||||
- name: epoch
|
- name: epoch
|
||||||
|
|
|
@ -276,6 +276,7 @@ func PutNamed(container []byte, signature interop.Signature,
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("added new container")
|
runtime.Log("added new container")
|
||||||
|
runtime.Notify("PutSuccess", containerID, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkNiceNameAvailable checks if nice name is available for the container.
|
// 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)
|
removeContainer(ctx, containerID, ownerID)
|
||||||
runtime.Log("remove container")
|
runtime.Log("remove container")
|
||||||
|
runtime.Notify("DeleteSuccess", containerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get method returns structure that contains stable marshaled Container structure,
|
// 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)
|
common.SetSerialized(ctx, key, rule)
|
||||||
|
|
||||||
runtime.Log("success")
|
runtime.Log("success")
|
||||||
|
runtime.Notify("SetEACLSuccess", containerID, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EACL method returns structure that contains stable marshaled EACLTable structure,
|
// EACL method returns structure that contains stable marshaled EACLTable structure,
|
||||||
|
|
|
@ -7,12 +7,22 @@ events:
|
||||||
parameters:
|
parameters:
|
||||||
- name: nodeInfo
|
- name: nodeInfo
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
|
- name: AddPeerSuccess
|
||||||
|
parameters:
|
||||||
|
- name: publicKey
|
||||||
|
type: PublicKey
|
||||||
- name: UpdateState
|
- name: UpdateState
|
||||||
parameters:
|
parameters:
|
||||||
- name: state
|
- name: state
|
||||||
type: Integer
|
type: Integer
|
||||||
- name: publicKey
|
- name: publicKey
|
||||||
type: PublicKey
|
type: PublicKey
|
||||||
|
- name: UpdateStateSuccess
|
||||||
|
parameters:
|
||||||
|
- name: publicKey
|
||||||
|
type: PublicKey
|
||||||
|
- name: state
|
||||||
|
type: Integer
|
||||||
- name: NewEpoch
|
- name: NewEpoch
|
||||||
parameters:
|
parameters:
|
||||||
- name: epoch
|
- name: epoch
|
||||||
|
|
|
@ -202,6 +202,9 @@ func AddPeerIR(nodeInfo []byte) {
|
||||||
common.CheckAlphabetWitness(common.AlphabetAddress())
|
common.CheckAlphabetWitness(common.AlphabetAddress())
|
||||||
|
|
||||||
addToNetmap(ctx, storageNode{info: nodeInfo})
|
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
|
// 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)
|
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
|
// V2 format
|
||||||
publicKey := nodeInfo[2:35] // offset:2, len:33
|
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)
|
common.CheckWitness(publicKey)
|
||||||
if notaryDisabled {
|
if notaryDisabled {
|
||||||
runtime.Notify("AddPeer", nodeInfo)
|
runtime.Notify("AddPeer", nodeInfo)
|
||||||
|
@ -256,6 +259,7 @@ func AddPeer(nodeInfo []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addToNetmap(ctx, candidate)
|
addToNetmap(ctx, candidate)
|
||||||
|
runtime.Notify("AddPeerSuccess", interop.PublicKey(publicKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateState method updates state of node from the network map candidate list.
|
// UpdateState method updates state of node from the network map candidate list.
|
||||||
|
@ -316,6 +320,8 @@ func UpdateState(state int, publicKey interop.PublicKey) {
|
||||||
default:
|
default:
|
||||||
panic("unsupported state")
|
panic("unsupported state")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runtime.Notify("UpdateStateSuccess", publicKey, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateStateIR method tries to change node state in the network map.
|
// UpdateStateIR method tries to change node state in the network map.
|
||||||
|
@ -335,6 +341,7 @@ func UpdateStateIR(state nodeState, publicKey interop.PublicKey) {
|
||||||
default:
|
default:
|
||||||
panic("unsupported state")
|
panic("unsupported state")
|
||||||
}
|
}
|
||||||
|
runtime.Notify("UpdateStateSuccess", publicKey, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEpoch method changes epoch number up to provided epochNum argument. Can
|
// NewEpoch method changes epoch number up to provided epochNum argument. Can
|
||||||
|
|
Loading…
Reference in a new issue