Description
The scanner listener reads each and every block from the chain and looks for StakeRequested
event for the given composer contract. Once the event is found it callbacks the facilitator with event data.
scanner listener keeps a record of the last block scanned so that it can resume the scanner listener from the same block height. For more details check the epic #1
The scanner listener can be for the origin and auxiliary chain.
The scanner listener should update the database tables.
This ticket is about defining the interfaces of all the functions in the scanner listener.
The proposed functions are provided for reference.
The implementer can think this in detail and can add/remove functions
We can call this as EventListner.
-
constructor.
- Acceptsmosaic-config
andfacilitator-config
.- Accepts Config object. (store in variable).
- Accepts object that cointains
{contractAddresss: [Event topics]}
. - Creates DB object. (store in variable). (Still in discussion)
-
function to scan the blocks in batches. (Start scan)
- Accepts
blockNumber
as a parameter. blockNumber
is an optional param, if this is provided then thescannerlistener will start scanning from that block, else it will start from the latest block.- Keep track of last block number that was scanned.
- Accepts
- [ ] function to update the last scanned block number.
- [ ] function to get transactions for the given block.
- [ ] function to get events from the given transaction.
- [ ] function to emit an event when StakeRequested event is found.
- function to stop the
scannerlistener (SIGTERM). (Update the ticket)
- [ ] function to updates stake_request
table status. (create a new ticket for this.)