frostfs-contract/nns/namestate.go
Evgenii Stratonikov 69b308e792 [#248] *: Fix integer types
When using contracts as a dependency, out-of-range `int` can cause
problems on 32-bit architectures. Contract byte-code hasn't changed.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-07-06 14:28:47 +03:00

31 lines
714 B
Go

package nns
import (
"github.com/nspcc-dev/neo-go/pkg/interop"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
)
// NameState represents domain name state.
type NameState struct {
Owner interop.Hash160
Name string
Expiration int64
Admin interop.Hash160
}
// ensureNotExpired panics if domain name is expired.
func (n NameState) ensureNotExpired() {
if int64(runtime.GetTime()) >= n.Expiration {
panic("name has expired")
}
}
// checkAdmin panics if script container is not signed by the domain name admin.
func (n NameState) checkAdmin() {
if runtime.CheckWitness(n.Owner) {
return
}
if n.Admin == nil || !runtime.CheckWitness(n.Admin) {
panic("not witnessed by admin")
}
}