rpc: fix Matches and marshalling for notification events

Close #1494. Marshalling went wrong due to the incorrect pointers usage.
Reproduced and fixed.
This commit is contained in:
Anna Shaleva 2020-10-19 13:44:20 +03:00
parent d58c50fb77
commit 64d1946fbb
3 changed files with 3 additions and 3 deletions

View file

@ -93,7 +93,7 @@ type notificationEventAux struct {
}
// MarshalJSON implements implements json.Marshaler interface.
func (ne *NotificationEvent) MarshalJSON() ([]byte, error) {
func (ne NotificationEvent) MarshalJSON() ([]byte, error) {
item, err := stackitem.ToJSONWithTypes(ne.Item)
if err != nil {
item = []byte(`"error: recursive reference"`)

View file

@ -1244,7 +1244,7 @@ chloop:
resp.Payload[0] = execution
case notification := <-s.notificationCh:
resp.Event = response.NotificationEventID
resp.Payload[0] = *notification
resp.Payload[0] = notification
case tx := <-s.transactionCh:
resp.Event = response.TransactionEventID
resp.Payload[0] = tx

View file

@ -72,7 +72,7 @@ func (f *feed) Matches(r *response.Notification) bool {
return senderOK && signerOK
case response.NotificationEventID:
filt := f.filter.(request.NotificationFilter)
notification := r.Payload[0].(state.NotificationEvent)
notification := r.Payload[0].(*state.NotificationEvent)
hashOk := filt.Contract == nil || notification.ScriptHash.Equals(*filt.Contract)
nameOk := filt.Name == nil || notification.Name == *filt.Name
return hashOk && nameOk