Commit 1678b0e9 authored by aniket-engg's avatar aniket-engg Committed by Aniket

logsManager and txExecution

parent 2aa25bc4
const async = require('async') import { eachOf } from 'async'
const crypto = require('crypto') import { randomBytes } from 'crypto'
class LogsManager { export class LogsManager {
notificationCallbacks
subscriptions
filters
filterTracking
oldLogs
constructor () { constructor () {
this.notificationCallbacks = [] this.notificationCallbacks = []
...@@ -12,7 +18,7 @@ class LogsManager { ...@@ -12,7 +18,7 @@ class LogsManager {
} }
checkBlock (blockNumber, block, web3) { checkBlock (blockNumber, block, web3) {
async.eachOf(block.transactions, (tx, i, next) => { eachOf(block.transactions, (tx, i, next) => {
let txHash = '0x' + tx.hash().toString('hex') let txHash = '0x' + tx.hash().toString('hex')
web3.eth.getTransactionReceipt(txHash, (_error, receipt) => { web3.eth.getTransactionReceipt(txHash, (_error, receipt) => {
...@@ -97,7 +103,7 @@ class LogsManager { ...@@ -97,7 +103,7 @@ class LogsManager {
} }
subscribe (params) { subscribe (params) {
let subscriptionId = '0x' + crypto.randomBytes(16).toString('hex') let subscriptionId = '0x' + randomBytes(16).toString('hex')
this.subscriptions[subscriptionId] = params this.subscriptions[subscriptionId] = params
return subscriptionId return subscriptionId
} }
...@@ -107,7 +113,7 @@ class LogsManager { ...@@ -107,7 +113,7 @@ class LogsManager {
} }
newFilter (filterType, params) { newFilter (filterType, params) {
const filterId = '0x' + crypto.randomBytes(16).toString('hex') const filterId = '0x' + randomBytes(16).toString('hex')
if (filterType === 'block' || filterType === 'pendingTransactions') { if (filterType === 'block' || filterType === 'pendingTransactions') {
this.filters[filterId] = { filterType } this.filters[filterId] = { filterType }
} }
...@@ -123,7 +129,7 @@ class LogsManager { ...@@ -123,7 +129,7 @@ class LogsManager {
} }
getLogsForFilter (filterId, logsOnly) { getLogsForFilter (filterId, logsOnly) {
const {filterType, params} = this.filter[filterId] const {filterType, params} = this.filters[filterId]
const tracking = this.filterTracking[filterId] const tracking = this.filterTracking[filterId]
if (logsOnly || filterType === 'filter') { if (logsOnly || filterType === 'filter') {
...@@ -161,5 +167,3 @@ class LogsManager { ...@@ -161,5 +167,3 @@ class LogsManager {
} }
} }
module.exports = LogsManager
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment