core: change notify implementation to save notifications

Fixes #453 and makes it possible to refer to these notifications later.
This commit is contained in:
Roman Khimov 2019-11-13 16:55:20 +03:00
parent 9134cc1c37
commit 5ce269c035
7 changed files with 128 additions and 15 deletions

View file

@ -343,8 +343,10 @@ func (ic *interopContext) runtimeCheckWitness(v *vm.VM) error {
// runtimeNotify should pass stack item to the notify plugin to handle it, but
// in neo-go the only meaningful thing to do here is to log.
func (ic *interopContext) runtimeNotify(v *vm.VM) error {
msg := fmt.Sprintf("%q", v.Estack().Pop().Bytes())
log.Infof("script %s notifies: %s", getContextScriptHash(v, 0), msg)
// It can be just about anything.
e := v.Estack().Pop()
ne := NotificationEvent{getContextScriptHash(v, 0), e.Item()}
ic.notifications = append(ic.notifications, ne)
return nil
}