[#1365] ir: Check homomorphic hash setting on `ContainerPut`

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
remotes/fyrchik/tree-errors
Pavel Karpy 2022-04-29 20:48:11 +03:00 committed by fyrchik
parent fa9c910648
commit 8a61d33c65
2 changed files with 27 additions and 0 deletions

View File

@ -82,6 +82,12 @@ func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
return fmt.Errorf("incorrect subnetwork: %w", err)
}
// check homomorphic hashing setting
err = checkHomomorphicHashing(cp.netState, cnr)
if err != nil {
return fmt.Errorf("incorrect homomorphic hashing setting: %w", err)
}
// check native name and zone
err = checkNNS(ctx, cnr)
if err != nil {
@ -237,3 +243,16 @@ func checkSubnet(subCli *morphsubnet.Client, cnr containerSDK.Container) error {
return nil
}
func checkHomomorphicHashing(ns NetworkState, cnr containerSDK.Container) error {
netSetting, err := ns.HomomorphicHashDisabled()
if err != nil {
return fmt.Errorf("could not get setting in contract: %w", err)
}
if cnrSetting := containerSDK.IsHomomorphicHashingDisabled(cnr); netSetting != cnrSetting {
return fmt.Errorf("network setting: %t, container setting: %t", netSetting, cnrSetting)
}
return nil
}

View File

@ -53,6 +53,14 @@ type NetworkState interface {
// Must return any error encountered
// which did not allow reading the value.
Epoch() (uint64, error)
// HomomorphicHashDisabled must return boolean that
// represents homomorphic network state:
// * true if hashing is disabled;
// * false if hashing is enabled.
//
// which did not allow reading the value.
HomomorphicHashDisabled() (bool, error)
}
const (