[#770] ir/container: Support notary Put

Implement `NotaryContractProcessor` by IR
container processor. Add support for notary
`put` container operation. Do not parse `put`
non-notary notifications in notary enabled
environment.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-08-25 14:35:17 +03:00 committed by Pavel Karpy
parent 9921358f09
commit 13f1273e82
3 changed files with 60 additions and 9 deletions

View file

@ -86,7 +86,15 @@ func (cp *Processor) checkPutContainer(e *containerEvent.Put) error {
}
func (cp *Processor) approvePutContainer(e *containerEvent.Put) {
err := cp.cnrClient.Put(e.Container(), e.PublicKey(), e.Signature(), e.SessionToken())
var err error
if nr := e.NotaryRequest(); nr != nil {
// put event was received via Notary service
err = cp.cnrClient.Morph().NotarySignAndInvokeTX(nr.MainTransaction)
} else {
// put event was received via notification service
err = cp.cnrClient.Put(e.Container(), e.PublicKey(), e.Signature(), e.SessionToken())
}
if err != nil {
cp.log.Error("could not approve put container",
zap.String("error", err.Error()),