[#55] policy: Swap signature check order

While implementing the changes for FrostFS ID it became obvious, that
committee signature check can be rather costly (`getCommittee` call +
multiaddress construction + checking witness). In real scenarious it
will mostly fail, so it makes sense do it last.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-11-28 11:51:24 +03:00
parent 0dda536d4a
commit f30fb324ff

View file

@ -47,14 +47,13 @@ func _deploy(data any, isUpdate bool) {
}
func checkAuthorization(ctx storage.Context) {
if runtime.CheckWitness(common.AlphabetAddress()) {
return
}
admin := getAdmin(ctx)
if admin != nil && runtime.CheckWitness(admin) {
return
}
if runtime.CheckWitness(common.AlphabetAddress()) {
return
}
panic(ErrNotAutorized)
}