Skip to content

The architecture of Event Manager

AionJayT edited this page Sep 17, 2020 · 1 revision

Introduction

The event manager is a light-weight and high efficiency module providing the asynchronous message delivery. The goal of this module is trying to decrease the module dependency between the module of the Aion blockchain kernel. Therefore, any module can register the events it want to receive and sent the events to notify the other module has subscribed the events.

Event Manager src

Before start to use the event manager, the kernel needs to register the predefined event callbacks to the event manager to enable the event dispatching abilities in the event manager. When the kernel generate a new event, the event can be added into the event manager by calling newEvent or newEvents.

EventExecuteService<src

To listening the events, you should use EventExecuteService to retrieve the events by setting the event filters. When the event happens, the Event dispatcher in the event manager will dispatch the events to EventExecuteService instances if the event filter has been setup.

Event src

Aion blockchain kernel defines 5 event categories, and Each event defines it own event callback. For example, in Block category, There are 3 event callback in the category: ONBLOCK0, ONTRACE0, and ONBEST0.

Handler src

The event handler is a dispatcher to dispatch the events belong to the same event category to pass events to the EventExecuteService through EventCallback src

Clone this wiki locally