From 891e26817073e970224ba33fc303241c8133c891 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 11 Dec 2024 14:36:26 +0300 Subject: [PATCH] [#138] frostfs: Remove AlphabetUpdate event from the configuration It does not exist in code. Refs #7. Signed-off-by: Evgenii Stratonikov --- frostfs/config.yml | 6 --- rpcclient/frostfs/client.go | 77 ------------------------------------- 2 files changed, 83 deletions(-) diff --git a/frostfs/config.yml b/frostfs/config.yml index e1198cc..b7220bb 100644 --- a/frostfs/config.yml +++ b/frostfs/config.yml @@ -47,12 +47,6 @@ events: type: ByteArray - name: keys type: Array - - name: AlphabetUpdate - parameters: - - name: id - type: ByteArray - - name: alphabet - type: Array - name: SetConfig parameters: - name: id diff --git a/rpcclient/frostfs/client.go b/rpcclient/frostfs/client.go index b49670d..057ae40 100644 --- a/rpcclient/frostfs/client.go +++ b/rpcclient/frostfs/client.go @@ -50,12 +50,6 @@ type UnbindEvent struct { Keys []any } -// AlphabetUpdateEvent represents "AlphabetUpdate" event emitted by the contract. -type AlphabetUpdateEvent struct { - Id []byte - Alphabet []any -} - // SetConfigEvent represents "SetConfig" event emitted by the contract. type SetConfigEvent struct { Id []byte @@ -710,77 +704,6 @@ func (e *UnbindEvent) FromStackItem(item *stackitem.Array) error { return nil } -// AlphabetUpdateEventsFromApplicationLog retrieves a set of all emitted events -// with "AlphabetUpdate" name from the provided [result.ApplicationLog]. -func AlphabetUpdateEventsFromApplicationLog(log *result.ApplicationLog) ([]*AlphabetUpdateEvent, error) { - if log == nil { - return nil, errors.New("nil application log") - } - - var res []*AlphabetUpdateEvent - for i, ex := range log.Executions { - for j, e := range ex.Events { - if e.Name != "AlphabetUpdate" { - continue - } - event := new(AlphabetUpdateEvent) - err := event.FromStackItem(e.Item) - if err != nil { - return nil, fmt.Errorf("failed to deserialize AlphabetUpdateEvent from stackitem (execution #%d, event #%d): %w", i, j, err) - } - res = append(res, event) - } - } - - return res, nil -} - -// FromStackItem converts provided [stackitem.Array] to AlphabetUpdateEvent or -// returns an error if it's not possible to do to so. -func (e *AlphabetUpdateEvent) FromStackItem(item *stackitem.Array) error { - if item == nil { - return errors.New("nil item") - } - arr, ok := item.Value().([]stackitem.Item) - if !ok { - return errors.New("not an array") - } - if len(arr) != 2 { - return errors.New("wrong number of structure elements") - } - - var ( - index = -1 - err error - ) - index++ - e.Id, err = arr[index].TryBytes() - if err != nil { - return fmt.Errorf("field Id: %w", err) - } - - index++ - e.Alphabet, err = func(item stackitem.Item) ([]any, error) { - arr, ok := item.Value().([]stackitem.Item) - if !ok { - return nil, errors.New("not an array") - } - res := make([]any, len(arr)) - for i := range res { - res[i], err = arr[i].Value(), error(nil) - if err != nil { - return nil, fmt.Errorf("item %d: %w", i, err) - } - } - return res, nil - }(arr[index]) - if err != nil { - return fmt.Errorf("field Alphabet: %w", err) - } - - return nil -} - // SetConfigEventsFromApplicationLog retrieves a set of all emitted events // with "SetConfig" name from the provided [result.ApplicationLog]. func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) { -- 2.45.2