forked from TrueCloudLab/frostfs-contract
[#184] *: Add ownerSize
constant
It consists of 1 byte prefix, script hash and 4 byte hash of the previous bytes. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
a2f5f7a74a
commit
5c4e44575a
1 changed files with 11 additions and 7 deletions
|
@ -18,6 +18,10 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ownerSize = 1 + interop.Hash160Len + 4
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
netmapContractKey = "netmapScriptHash"
|
netmapContractKey = "netmapScriptHash"
|
||||||
containerContractKey = "containerScriptHash"
|
containerContractKey = "containerScriptHash"
|
||||||
|
@ -33,7 +37,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
for iterator.Next(it) {
|
for iterator.Next(it) {
|
||||||
kv := iterator.Value(it).([][]byte)
|
kv := iterator.Value(it).([][]byte)
|
||||||
// V2 format
|
// V2 format
|
||||||
if len(kv[0]) == 25 {
|
if len(kv[0]) == ownerSize {
|
||||||
info := std.Deserialize(kv[1]).(UserInfo)
|
info := std.Deserialize(kv[1]).(UserInfo)
|
||||||
key := append([]byte{ownerKeysPrefix}, kv[0]...)
|
key := append([]byte{ownerKeysPrefix}, kv[0]...)
|
||||||
for i := range info.Keys {
|
for i := range info.Keys {
|
||||||
|
@ -83,11 +87,11 @@ func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
// AddKey binds list of provided public keys to OwnerID. Can be invoked only by
|
// AddKey binds list of provided public keys to OwnerID. Can be invoked only by
|
||||||
// Alphabet nodes.
|
// Alphabet nodes.
|
||||||
//
|
//
|
||||||
// This method panics if OwnerID is not 25 byte or public key is not 33 byte long.
|
// This method panics if OwnerID is not ownerSize byte or public key is not 33 byte long.
|
||||||
// If key is already bound, ignores it.
|
// If key is already bound, ignores it.
|
||||||
func AddKey(owner []byte, keys []interop.PublicKey) {
|
func AddKey(owner []byte, keys []interop.PublicKey) {
|
||||||
// V2 format
|
// V2 format
|
||||||
if len(owner) != 25 {
|
if len(owner) != ownerSize {
|
||||||
panic("incorrect owner")
|
panic("incorrect owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,11 +151,11 @@ func AddKey(owner []byte, keys []interop.PublicKey) {
|
||||||
// RemoveKey unbinds provided public keys from OwnerID. Can be invoked only by
|
// RemoveKey unbinds provided public keys from OwnerID. Can be invoked only by
|
||||||
// Alphabet nodes.
|
// Alphabet nodes.
|
||||||
//
|
//
|
||||||
// This method panics if OwnerID is not 25 byte or public key is not 33 byte long.
|
// This method panics if OwnerID is not ownerSize byte or public key is not 33 byte long.
|
||||||
// If key is already unbound, ignores it.
|
// If key is already unbound, ignores it.
|
||||||
func RemoveKey(owner []byte, keys []interop.PublicKey) {
|
func RemoveKey(owner []byte, keys []interop.PublicKey) {
|
||||||
// V2 format
|
// V2 format
|
||||||
if len(owner) != 25 {
|
if len(owner) != ownerSize {
|
||||||
panic("incorrect owner")
|
panic("incorrect owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +205,10 @@ func RemoveKey(owner []byte, keys []interop.PublicKey) {
|
||||||
|
|
||||||
// Key method returns list of 33-byte public keys bound with OwnerID.
|
// Key method returns list of 33-byte public keys bound with OwnerID.
|
||||||
//
|
//
|
||||||
// This method panics if owner is not 25 byte long.
|
// This method panics if owner is not ownerSize byte long.
|
||||||
func Key(owner []byte) [][]byte {
|
func Key(owner []byte) [][]byte {
|
||||||
// V2 format
|
// V2 format
|
||||||
if len(owner) != 25 {
|
if len(owner) != ownerSize {
|
||||||
panic("incorrect owner")
|
panic("incorrect owner")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue