From aae1db20717cf8ccafd1175aee6988fe8e51f1c6 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 14 Feb 2014 16:49:22 -0300 Subject: [PATCH] minor bugfixes --- lib/HistoricSync.js | 2 +- lib/PeerSync.js | 12 ++++-------- lib/Sync.js | 7 +------ lib/TransactionDb.js | 2 +- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/lib/HistoricSync.js b/lib/HistoricSync.js index 2deafc4..36f53dd 100644 --- a/lib/HistoricSync.js +++ b/lib/HistoricSync.js @@ -297,7 +297,7 @@ function spec() { if (blockInfo && blockInfo.hash) { self.syncedBlocks++; - } + } else { self.endTs = parseInt(Date.now()); self.status = 'finished'; diff --git a/lib/PeerSync.js b/lib/PeerSync.js index f10fafb..15b1438 100644 --- a/lib/PeerSync.js +++ b/lib/PeerSync.js @@ -11,6 +11,7 @@ function spec() { var networks = require('bitcore/networks'); var peerdb_fn = 'peerdb.json'; + function PeerSync() {} @@ -22,7 +23,7 @@ function spec() { this.sync = new Sync(); this.PeerManager = require('bitcore/PeerManager').createClass({ - network: (config.network === 'testnet' ? networks.testnet : networks.livenet) + network: (config.network === 'testnet' ? networks.testnet : networks.livenet) }); this.peerman = new this.PeerManager(); this.load_peers(); @@ -51,10 +52,6 @@ function spec() { PeerSync.prototype.handleInv = function(info) { var invs = info.message.invs; - invs.forEach(function(inv) { - console.log('[p2p_sync] Handle inv for a ' + CoinConst.MSG.to_str(inv.type)); - }); - // TODO: should limit the invs to objects we haven't seen yet info.conn.sendGetData(invs); }; @@ -85,7 +82,7 @@ function spec() { this.sync.storeTipBlock({ 'hash': blockHash, - 'tx': tx_hashes, + 'tx': tx_hashes, 'previousblockhash': coinUtil.formatHashFull(block.prev_hash), }, self.allowReorgs, function(err) { if (err) { @@ -97,7 +94,7 @@ function spec() { PeerSync.prototype.handle_connected = function(data) { var peerman = data.pm; var peers_n = peerman.peers.length; - console.log('[p2p_sync] Connected to ' + peers_n + ' peer' + (peers_n !== 1 ? 's': '')); + console.log('[p2p_sync] Connected to ' + peers_n + ' peer' + (peers_n !== 1 ? 's' : '')); }; PeerSync.prototype.run = function() { @@ -132,4 +129,3 @@ function spec() { } module.defineClass(spec); - diff --git a/lib/Sync.js b/lib/Sync.js index c162ce3..a6afc6d 100644 --- a/lib/Sync.js +++ b/lib/Sync.js @@ -257,11 +257,6 @@ function spec() { ); }; - Sync.prototype._handleBroadcast = function() { - var self = this; - console.log('broadcast:' + self.opts.shouldBroadcast); - }; - Sync.prototype.handleTxForAddress = function(data) { if (this.opts.shouldBroadcast) { @@ -271,7 +266,7 @@ function spec() { Sync.prototype.handleNewTx = function(data) { if (this.opts.shouldBroadcast) { - sockets.broadcastTx(data.txid); + sockets.broadcastTx(data.tx); } }; diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index d676890..e762aeb 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -595,7 +595,7 @@ function spec(b) { }); } self.emit('new_tx', { - txid: tx.txid + tx: tx }); return cb(err);