rpcsrv: handle block aer errors in getblocknotifications

Ignoring them is not correct. Notice that block-level aers are always present
and if filtering returns nothing the value of the resulting slice still remains
nil, so the behavior is the same.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2025-02-11 15:52:41 +03:00
parent cb4aba497e
commit d1926e4fb0

View file

@ -3239,9 +3239,10 @@ func (s *Server) getBlockNotifications(reqParams params.Params) (any, *neorpc.Er
notifications := &result.BlockNotifications{}
aers, err := s.chain.GetAppExecResults(block.Hash(), trigger.OnPersist)
if err == nil && len(aers) > 0 {
notifications.PrePersistNotifications = processAppExecResults([]state.AppExecResult{aers[0]}, filter)
if err != nil {
return nil, neorpc.NewInternalServerError("failed to get app exec results for onpersist")
}
notifications.PrePersistNotifications = processAppExecResults([]state.AppExecResult{aers[0]}, filter)
for _, txHash := range block.Transactions {
aers, err := s.chain.GetAppExecResults(txHash.Hash(), trigger.Application)
@ -3252,9 +3253,10 @@ func (s *Server) getBlockNotifications(reqParams params.Params) (any, *neorpc.Er
}
aers, err = s.chain.GetAppExecResults(block.Hash(), trigger.PostPersist)
if err == nil && len(aers) > 0 {
notifications.PostPersistNotifications = processAppExecResults([]state.AppExecResult{aers[0]}, filter)
if err != nil {
return nil, neorpc.NewInternalServerError("failed to get app exec results for postpersist")
}
notifications.PostPersistNotifications = processAppExecResults([]state.AppExecResult{aers[0]}, filter)
return notifications, nil
}