Comparing version 2.0.4 to 2.1.0
{ | ||
"name": "basecoin", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "Client for Tendermint's basecoin cryptocurrency", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -47,3 +47,8 @@ 'use strict' | ||
if (err) return this.emit('error', err) | ||
this.emit('block', event[1].data[1].block) | ||
let { block } = event[1].data[1] | ||
block.data.txs = block.data.txs.map((txHex) => { | ||
let txBytes = Buffer.from(txHex, 'hex') | ||
return Tx.decode(txBytes) | ||
}) | ||
this.emit('block', block) | ||
}) | ||
@@ -50,0 +55,0 @@ } |
@@ -94,2 +94,6 @@ 'use strict' | ||
* _initialSync (next) { | ||
this.onceReady(() => { | ||
this.basecoin.on('block', this._processBlock.bind(this)) | ||
}) | ||
let txs = yield this.basecoin.fetchTxs(this.addresses, this.state.syncHeight, next) | ||
@@ -139,2 +143,14 @@ this.state.syncHeight = txs.height | ||
* _processBlock (block) { | ||
let { header, data } = block | ||
let time = new Date(header.time).getTime() | ||
this.state.syncHeight = header.height | ||
for (let tx of data.txs) { | ||
yield this._processTx(tx, time) | ||
} | ||
yield this.save() | ||
} | ||
* _processTx (tx, time) { | ||
@@ -141,0 +157,0 @@ let myInputs = tx.inputs.filter((input) => |
574
100704
10