From 0f668bd7a82ba5405968da66ed0b2563c9ae66f0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 2 Aug 2017 10:35:13 +0200 Subject: [PATCH] add and use event "newTransaction" --- src/app.js | 23 ++++++++++------------- src/app/txListener.js | 5 ++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app.js b/src/app.js index 11bf5e2b4b..635fe705d1 100644 --- a/src/app.js +++ b/src/app.js @@ -873,20 +873,17 @@ function run () { txlistener.startListening() - txlistener.event.register('newBlock', (block) => { - for (var t in block.transactions) { - var tx = block.transactions[t] - var resolvedTransaction = txlistener.resolvedTransaction(tx.hash) - var address = null - if (resolvedTransaction) { - address = resolvedTransaction.contractAddress ? resolvedTransaction.contractAddress : tx.to - } - console.log({ - tx: tx, - resolvedContract: txlistener.resolvedContract(address), - resolvedTransaction: resolvedTransaction - }) + txlistener.event.register('newTransaction', (tx) => { + var resolvedTransaction = txlistener.resolvedTransaction(tx.hash) + var address = null + if (resolvedTransaction) { + address = resolvedTransaction.contractAddress ? resolvedTransaction.contractAddress : tx.to } + console.log({ + tx: tx, + resolvedContract: txlistener.resolvedContract(address), + resolvedTransaction: resolvedTransaction + }) }) // ----------------- autoCompile ----------------- diff --git a/src/app/txListener.js b/src/app/txListener.js index 5967a66de7..751aadb902 100644 --- a/src/app/txListener.js +++ b/src/app/txListener.js @@ -124,7 +124,10 @@ class TxListener { _resolve (block, callback) { async.each(block.transactions, (tx, cb) => { - this._resolveTx(tx, cb) + this._resolveTx(tx, () => { + this.event.trigger('newTransaction', [tx]) + cb() + }) }, () => { callback() })