You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
577 B
19 lines
577 B
const BlockTracker = require('eth-block-tracker')
|
|
|
|
/**
|
|
* Creates a block tracker that sends platform events on success and failure
|
|
*/
|
|
module.exports = function createBlockTracker (args, platform) {
|
|
const blockTracker = new BlockTracker(args)
|
|
blockTracker.on('latest', () => {
|
|
if (platform && platform.sendMessage) {
|
|
platform.sendMessage({ action: 'ethereum-ping-success' })
|
|
}
|
|
})
|
|
blockTracker.on('error', () => {
|
|
if (platform && platform.sendMessage) {
|
|
platform.sendMessage({ action: 'ethereum-ping-error' })
|
|
}
|
|
})
|
|
return blockTracker
|
|
}
|
|
|