state: drop compatibility code for NEOBalance

A part of #3454.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2024-11-19 21:39:40 +03:00
parent 7683f4366d
commit 125f757988
3 changed files with 6 additions and 14 deletions

View file

@ -25,13 +25,6 @@ APIs/commands/configurations will be removed and here is a list of scheduled
breaking changes. Consider changing your code/scripts/configurations if you're
using anything mentioned here.
## `NEOBalance` from stack item
We check struct items count before convert LastGasPerVote to let RPC client be compatible with
old versions.
Removal of this compatiblility code is scheduled for Jun-Jul 2024.
## `serv_node_version` Prometheus gauge metric
This metric is replaced by the new `neogo_version` and `server_id` Prometheus gauge

View file

@ -133,7 +133,7 @@ func (s *NEOBalance) ToStackItem() (stackitem.Item, error) {
// FromStackItem converts stackitem.Item to NEOBalance.
func (s *NEOBalance) FromStackItem(item stackitem.Item) error {
structItem, ok := item.Value().([]stackitem.Item)
if !ok || len(structItem) < 3 {
if !ok || len(structItem) < 4 {
return errors.New("invalid stackitem length")
}
balance, err := structItem[0].TryInteger()
@ -159,12 +159,10 @@ func (s *NEOBalance) FromStackItem(item stackitem.Item) error {
}
s.VoteTo = pub
}
if len(structItem) >= 4 {
lastGasPerVote, err := structItem[3].TryInteger()
if err != nil {
return fmt.Errorf("invalid last vote reward per neo stackitem: %w", err)
}
s.LastGasPerVote = *lastGasPerVote
lastGasPerVote, err := structItem[3].TryInteger()
if err != nil {
return fmt.Errorf("invalid last vote reward per neo stackitem: %w", err)
}
s.LastGasPerVote = *lastGasPerVote
return nil
}

View file

@ -105,6 +105,7 @@ func TestGetAccountState(t *testing.T) {
stackitem.Make(100500),
stackitem.Make(42),
stackitem.Null{},
stackitem.Make(0),
}),
},
}