Commit 0f668bd7 authored by yann300's avatar yann300

add and use event "newTransaction"

parent 93bc2a54
...@@ -873,20 +873,17 @@ function run () { ...@@ -873,20 +873,17 @@ function run () {
txlistener.startListening() txlistener.startListening()
txlistener.event.register('newBlock', (block) => { txlistener.event.register('newTransaction', (tx) => {
for (var t in block.transactions) { var resolvedTransaction = txlistener.resolvedTransaction(tx.hash)
var tx = block.transactions[t] var address = null
var resolvedTransaction = txlistener.resolvedTransaction(tx.hash) if (resolvedTransaction) {
var address = null address = resolvedTransaction.contractAddress ? resolvedTransaction.contractAddress : tx.to
if (resolvedTransaction) {
address = resolvedTransaction.contractAddress ? resolvedTransaction.contractAddress : tx.to
}
console.log({
tx: tx,
resolvedContract: txlistener.resolvedContract(address),
resolvedTransaction: resolvedTransaction
})
} }
console.log({
tx: tx,
resolvedContract: txlistener.resolvedContract(address),
resolvedTransaction: resolvedTransaction
})
}) })
// ----------------- autoCompile ----------------- // ----------------- autoCompile -----------------
......
...@@ -124,7 +124,10 @@ class TxListener { ...@@ -124,7 +124,10 @@ class TxListener {
_resolve (block, callback) { _resolve (block, callback) {
async.each(block.transactions, (tx, cb) => { async.each(block.transactions, (tx, cb) => {
this._resolveTx(tx, cb) this._resolveTx(tx, () => {
this.event.trigger('newTransaction', [tx])
cb()
})
}, () => { }, () => {
callback() callback()
}) })
......
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