more renaming.

This commit is contained in:
Christopher Jeffrey 2016-02-19 22:06:47 -08:00
parent 3c29e20df2
commit d48d9d44ee

View File

@ -253,6 +253,7 @@ Pool.prototype.getBlocks = function getBlocks(peer, top, stop) {
self.chain.getLocatorAsync(top, function(err, locator) { self.chain.getLocatorAsync(top, function(err, locator) {
if (err) if (err)
throw err; throw err;
peer.getBlocks(locator, stop); peer.getBlocks(locator, stop);
}); });
}); });
@ -265,6 +266,7 @@ Pool.prototype.loadOrphan = function loadOrphan(peer, top, orphan) {
self.chain.getLocatorAsync(top, function(err, locator) { self.chain.getLocatorAsync(top, function(err, locator) {
if (err) if (err)
throw err; throw err;
peer.getBlocks( peer.getBlocks(
locator, locator,
self.chain.getOrphanRoot(orphan) self.chain.getOrphanRoot(orphan)
@ -279,6 +281,7 @@ Pool.prototype.getHeaders = function getHeaders(peer, top, stop) {
self.chain.getLocatorAsync(top, function(err, locator) { self.chain.getLocatorAsync(top, function(err, locator) {
if (err) if (err)
throw err; throw err;
peer.getHeaders(locator, stop); peer.getHeaders(locator, stop);
}); });
}); });
@ -1424,12 +1427,12 @@ Pool.prototype.search = function search(id, range, callback) {
} }
}; };
Pool.prototype.getData = function getData(peer, type, hash, options, cb) { Pool.prototype.getData = function getData(peer, type, hash, options, callback) {
var self = this; var self = this;
var item; var item;
if (typeof options === 'function') { if (typeof options === 'function') {
cb = options; callback = options;
options = {}; options = {};
} }
@ -1443,8 +1446,8 @@ Pool.prototype.getData = function getData(peer, type, hash, options, cb) {
hash = utils.toHex(hash); hash = utils.toHex(hash);
if (this.request.map[hash]) { if (this.request.map[hash]) {
if (cb) if (callback)
this.request.map[hash].cb.push(cb); this.request.map[hash].callback.push(callback);
return; return;
} }
@ -1456,7 +1459,7 @@ Pool.prototype.getData = function getData(peer, type, hash, options, cb) {
if (options.noQueue) if (options.noQueue)
return; return;
item = new LoadRequest(this, peer, type, hash, cb); item = new LoadRequest(this, peer, type, hash, callback);
if (type === 'tx') { if (type === 'tx') {
if (peer.queue.tx.length === 0) { if (peer.queue.tx.length === 0) {
@ -1542,19 +1545,19 @@ Pool.prototype.fulfill = function fulfill(hash) {
item.finish(); item.finish();
item.cb.forEach(function(cb) { item.callback.forEach(function(callback) {
cb(); callback();
}); });
return item; return item;
}; };
Pool.prototype.getBlock = function getBlock(hash, cb) { Pool.prototype.getBlock = function getBlock(hash, callback) {
if (!this.peers.load) if (!this.peers.load)
return setTimeout(this.getBlock.bind(this, hash, cb), 1000); return setTimeout(this.getBlock.bind(this, hash, callback), 1000);
this.getData(this.peers.load, 'block', hash, { force: true }, function(block) { this.getData(this.peers.load, 'block', hash, { force: true }, function(block) {
cb(null, block); callback(null, block);
}); });
}; };
@ -1562,28 +1565,28 @@ Pool.prototype.sendBlock = function sendBlock(block) {
return this.broadcast(block); return this.broadcast(block);
}; };
Pool.prototype.getTX = function getTX(hash, range, cb) { Pool.prototype.getTX = function getTX(hash, range, callback) {
var self = this; var self = this;
var cbs, tx, found, delta; var cbs, tx, found, delta;
if (!this.peers.load) if (!this.peers.load)
return setTimeout(this.getTX.bind(this, hash, cb), 1000); return setTimeout(this.getTX.bind(this, hash, range, callback), 1000);
if (!this.options.spv) if (!this.options.spv)
return cb(new Error('Cannot get tx with full node')); return callback(new Error('Cannot get tx with full node'));
hash = utils.toHex(hash); hash = utils.toHex(hash);
if (typeof range === 'function') { if (typeof range === 'function') {
cb = range; callback = range;
range = null; range = null;
} }
// Do not perform duplicate searches // Do not perform duplicate searches
if (this.validate.map[hash]) if (this.validate.map[hash])
return this.validate.map[hash].push(cb); return this.validate.map[hash].push(callback);
cbs = [cb]; cbs = [callback];
this.validate.map[hash] = cbs; this.validate.map[hash] = cbs;
// Add request without queueing it to get notification at the time of load // Add request without queueing it to get notification at the time of load
@ -1605,8 +1608,8 @@ Pool.prototype.getTX = function getTX(hash, range, cb) {
function done(err, tx, range) { function done(err, tx, range) {
delete self.validate.map[hash]; delete self.validate.map[hash];
cbs.forEach(function(cb) { cbs.forEach(function(callback) {
cb(err, tx, range); callback(err, tx, range);
}); });
} }
@ -1880,15 +1883,15 @@ Pool.prototype.isMisbehaving = function isMisbehaving(host) {
* LoadRequest * LoadRequest
*/ */
function LoadRequest(pool, peer, type, hash, cb) { function LoadRequest(pool, peer, type, hash, callback) {
this.pool = pool; this.pool = pool;
this.peer = peer; this.peer = peer;
this.type = type; this.type = type;
this.hash = hash; this.hash = hash;
this.cb = []; this.callback = [];
if (cb) if (callback)
this.cb.push(cb); this.callback.push(callback);
this._finish = this.finish.bind(this); this._finish = this.finish.bind(this);
} }