[#54] morph: Revise MorphRuleChainStorage interface

* Split MorphRuleChainStorage interface by moving read-only
  methods to a separate interface MorphRuleChainStorageReader.

Signed-off-by: Airat Arifullin <aarifullin@yadro.com>
This commit is contained in:
aarifullin 2024-02-26 18:19:37 +03:00 committed by Evgenii Stratonikov
parent c960b1b088
commit 9e66ce59c6
2 changed files with 21 additions and 3 deletions

View file

@ -52,3 +52,11 @@ func (s *inmemoryMorphRuleChainStorage) ListMorphRuleChains(name chain.Name, tar
} }
return nil, engine.ErrUnknownTarget return nil, engine.ErrUnknownTarget
} }
func (s *inmemoryMorphRuleChainStorage) GetAdmin() (util.Uint160, error) {
panic("not implemented")
}
func (s *inmemoryMorphRuleChainStorage) SetAdmin(_ util.Uint160) (util.Uint256, uint32, error) {
panic("not implemented")
}

View file

@ -93,17 +93,27 @@ func ContainerTarget(container string) Target {
} }
} }
// MorphRuleChainStorage is the interface to manage chains from the chain storage. // MorphRuleChainStorageReader is the interface that provides read-only methods to receive
// data like chains, target or admin from a chain storage.
type MorphRuleChainStorageReader interface {
// ListMorphRuleChains just lists deserialized chains.
ListMorphRuleChains(name chain.Name, target Target) ([]*chain.Chain, error)
GetAdmin() (util.Uint160, error)
}
// MorphRuleChainStorage is the interface to read and manage data within a chain storage.
// Basically, this implies that the storage manages rules stored in policy contract. // Basically, this implies that the storage manages rules stored in policy contract.
type MorphRuleChainStorage interface { type MorphRuleChainStorage interface {
MorphRuleChainStorageReader
// AddMorphRuleChain adds a chain rule to the policy contract and returns transaction hash, VUB and error. // AddMorphRuleChain adds a chain rule to the policy contract and returns transaction hash, VUB and error.
AddMorphRuleChain(name chain.Name, target Target, c *chain.Chain) (util.Uint256, uint32, error) AddMorphRuleChain(name chain.Name, target Target, c *chain.Chain) (util.Uint256, uint32, error)
// RemoveMorphRuleChain removes a chain rule to the policy contract and returns transaction hash, VUB and error. // RemoveMorphRuleChain removes a chain rule to the policy contract and returns transaction hash, VUB and error.
RemoveMorphRuleChain(name chain.Name, target Target, chainID chain.ID) (util.Uint256, uint32, error) RemoveMorphRuleChain(name chain.Name, target Target, chainID chain.ID) (util.Uint256, uint32, error)
// ListMorphRuleChains just lists deserialized chains. SetAdmin(addr util.Uint160) (util.Uint256, uint32, error)
ListMorphRuleChains(name chain.Name, target Target) ([]*chain.Chain, error)
} }
// Engine is the interface that provides methods to check request permissions checking // Engine is the interface that provides methods to check request permissions checking