forked from TrueCloudLab/frostfs-node
[#973] ir: Listen and process Put/Delete events of Subnet contract
Define notification events, implement parsers. Add morph client of Subnet contract. Listen, verify and approve events in Inner Ring app. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
214c2bd0cb
commit
41eaa1e246
22 changed files with 1278 additions and 12 deletions
44
pkg/innerring/processors/subnet/delete.go
Normal file
44
pkg/innerring/processors/subnet/delete.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package subnetevents
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
subnetid "github.com/nspcc-dev/neofs-sdk-go/subnet/id"
|
||||
)
|
||||
|
||||
// Delete represents notification about NeoFS subnet removal.
|
||||
// Generated by a contract when intending to delete a subnet.
|
||||
type Delete interface {
|
||||
// Contains ID of the subnet to be removed.
|
||||
eventWithID
|
||||
}
|
||||
|
||||
// DeleteValidator asserts intent to remove a subnet.
|
||||
type DeleteValidator struct{}
|
||||
|
||||
// Assert processes the attempt to remove a subnet. Approves the removal through nil return.
|
||||
//
|
||||
// All read errors of Delete are forwarded.
|
||||
//
|
||||
// Returns an error on:
|
||||
// * zero subnet creation;
|
||||
// * empty ID or different from the one wired into info;
|
||||
// * empty owner ID or different from the one wired into info.
|
||||
func (x DeleteValidator) Assert(event Delete) error {
|
||||
var err error
|
||||
|
||||
// read ID
|
||||
var id subnetid.ID
|
||||
if err = event.ReadID(&id); err != nil {
|
||||
return fmt.Errorf("read ID: %w", err)
|
||||
}
|
||||
|
||||
// prevent zero subnet removal
|
||||
if subnetid.IsZero(id) {
|
||||
return zeroSubnetOp{
|
||||
op: "removal",
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue