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.
20 lines
577 B
20 lines
577 B
6 years ago
|
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
|
||
|
}
|