forked from TrueCloudLab/frostfs-contract
[#74] Add notary disabled option to contracts
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7317388b4d
commit
622a83e014
8 changed files with 72 additions and 14 deletions
|
@ -19,6 +19,8 @@ const (
|
|||
totalKey = "threshold"
|
||||
nameKey = "name"
|
||||
|
||||
notaryDisabledKey = "notary"
|
||||
|
||||
version = 1
|
||||
)
|
||||
|
||||
|
@ -30,7 +32,7 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
func Init(owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name string, index, total int) {
|
||||
func Init(notaryDisabled bool, owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name string, index, total int) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -48,6 +50,12 @@ func Init(owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name str
|
|||
storage.Put(ctx, indexKey, index)
|
||||
storage.Put(ctx, totalKey, total)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log(name + " contract initialized")
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,11 @@ const (
|
|||
version = 1
|
||||
|
||||
netmapContractKey = "netmapScriptHash"
|
||||
|
||||
notaryDisabledKey = "notary"
|
||||
)
|
||||
|
||||
func Init(owner interop.Hash160, addrNetmap interop.Hash160) {
|
||||
func Init(notaryDisabled bool, owner interop.Hash160, addrNetmap interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -54,6 +56,9 @@ func Init(owner interop.Hash160, addrNetmap interop.Hash160) {
|
|||
storage.Put(ctx, common.OwnerKey, owner)
|
||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
|
||||
runtime.Log("audit contract initialized")
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ const (
|
|||
|
||||
netmapContractKey = "netmapScriptHash"
|
||||
containerContractKey = "containerScriptHash"
|
||||
notaryDisabledKey = "notary"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -62,7 +63,7 @@ func init() {
|
|||
token = CreateToken()
|
||||
}
|
||||
|
||||
func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
||||
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -77,6 +78,12 @@ func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
|||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||
storage.Put(ctx, containerContractKey, addrContainer)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log("balance contract initialized")
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ const (
|
|||
neofsIDContractKey = "identityScriptHash"
|
||||
balanceContractKey = "balanceScriptHash"
|
||||
netmapContractKey = "netmapScriptHash"
|
||||
notaryDisabledKey = "notary"
|
||||
|
||||
containerFeeKey = "ContainerFee"
|
||||
|
||||
containerIDSize = 32 // SHA256 size
|
||||
|
@ -53,7 +55,7 @@ var (
|
|||
eACLPrefix = []byte("eACL")
|
||||
)
|
||||
|
||||
func Init(owner, addrNetmap, addrBalance, addrID interop.Hash160) {
|
||||
func Init(notaryDisabled bool, owner, addrNetmap, addrBalance, addrID interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -69,6 +71,12 @@ func Init(owner, addrNetmap, addrBalance, addrID interop.Hash160) {
|
|||
storage.Put(ctx, balanceContractKey, addrBalance)
|
||||
storage.Put(ctx, neofsIDContractKey, addrID)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log("container contract initialized")
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ const (
|
|||
|
||||
alphabetKey = "alphabet"
|
||||
candidatesKey = "candidates"
|
||||
notaryDisabledKey = "notary"
|
||||
|
||||
processingContractKey = "processingScriptHash"
|
||||
|
||||
|
@ -75,7 +76,7 @@ var (
|
|||
)
|
||||
|
||||
// Init set up initial alphabet node keys.
|
||||
func Init(owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
|
||||
func Init(notaryDisabled bool, owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -107,6 +108,12 @@ func Init(owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
|
|||
storage.Put(ctx, common.OwnerKey, owner)
|
||||
storage.Put(ctx, processingContractKey, addrProc)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log("neofs: contract initialized")
|
||||
|
||||
return true
|
||||
|
|
|
@ -20,9 +20,10 @@ const (
|
|||
|
||||
netmapContractKey = "netmapScriptHash"
|
||||
containerContractKey = "containerScriptHash"
|
||||
notaryDisabledKey = "notary"
|
||||
)
|
||||
|
||||
func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
||||
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -37,6 +38,12 @@ func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
|||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||
storage.Put(ctx, containerContractKey, addrContainer)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log("neofsid contract initialized")
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ const (
|
|||
|
||||
netmapKey = "netmap"
|
||||
configuredKey = "initconfig"
|
||||
notaryDisabledKey = "notary"
|
||||
|
||||
snapshot0Key = "snapshotCurrent"
|
||||
snapshot1Key = "snapshotPrevious"
|
||||
|
@ -41,6 +42,7 @@ const (
|
|||
|
||||
containerContractKey = "containerScriptHash"
|
||||
balanceContractKey = "balanceScriptHash"
|
||||
|
||||
cleanupEpochMethod = "newEpoch"
|
||||
)
|
||||
|
||||
|
@ -56,7 +58,7 @@ var (
|
|||
|
||||
// Init function sets up initial list of inner ring public keys and should
|
||||
// be invoked once at neofs infrastructure setup.
|
||||
func Init(owner, addrBalance, addrContainer interop.Hash160) {
|
||||
func Init(notaryDisabled bool, owner, addrBalance, addrContainer interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -80,6 +82,12 @@ func Init(owner, addrBalance, addrContainer interop.Hash160) {
|
|||
storage.Put(ctx, balanceContractKey, addrBalance)
|
||||
storage.Put(ctx, containerContractKey, addrContainer)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log("netmap contract initialized")
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
notaryDisabledKey = "notary"
|
||||
|
||||
version = 1
|
||||
)
|
||||
|
||||
func Init(owner interop.Hash160) {
|
||||
func Init(notaryDisabled bool, owner interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
if !common.HasUpdateAccess(ctx) {
|
||||
|
@ -23,6 +25,12 @@ func Init(owner interop.Hash160) {
|
|||
|
||||
storage.Put(ctx, common.OwnerKey, owner)
|
||||
|
||||
// initialize the way to collect signatures
|
||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||
if notaryDisabled {
|
||||
common.InitVote(ctx)
|
||||
}
|
||||
|
||||
runtime.Log("reputation contract initialized")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue