more renaming.
This commit is contained in:
parent
3c29e20df2
commit
d48d9d44ee
@ -253,6 +253,7 @@ Pool.prototype.getBlocks = function getBlocks(peer, top, stop) {
|
||||
self.chain.getLocatorAsync(top, function(err, locator) {
|
||||
if (err)
|
||||
throw err;
|
||||
|
||||
peer.getBlocks(locator, stop);
|
||||
});
|
||||
});
|
||||
@ -265,6 +266,7 @@ Pool.prototype.loadOrphan = function loadOrphan(peer, top, orphan) {
|
||||
self.chain.getLocatorAsync(top, function(err, locator) {
|
||||
if (err)
|
||||
throw err;
|
||||
|
||||
peer.getBlocks(
|
||||
locator,
|
||||
self.chain.getOrphanRoot(orphan)
|
||||
@ -279,6 +281,7 @@ Pool.prototype.getHeaders = function getHeaders(peer, top, stop) {
|
||||
self.chain.getLocatorAsync(top, function(err, locator) {
|
||||
if (err)
|
||||
throw err;
|
||||
|
||||
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 item;
|
||||
|
||||
if (typeof options === 'function') {
|
||||
cb = options;
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
@ -1443,8 +1446,8 @@ Pool.prototype.getData = function getData(peer, type, hash, options, cb) {
|
||||
hash = utils.toHex(hash);
|
||||
|
||||
if (this.request.map[hash]) {
|
||||
if (cb)
|
||||
this.request.map[hash].cb.push(cb);
|
||||
if (callback)
|
||||
this.request.map[hash].callback.push(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1456,7 +1459,7 @@ Pool.prototype.getData = function getData(peer, type, hash, options, cb) {
|
||||
if (options.noQueue)
|
||||
return;
|
||||
|
||||
item = new LoadRequest(this, peer, type, hash, cb);
|
||||
item = new LoadRequest(this, peer, type, hash, callback);
|
||||
|
||||
if (type === 'tx') {
|
||||
if (peer.queue.tx.length === 0) {
|
||||
@ -1542,19 +1545,19 @@ Pool.prototype.fulfill = function fulfill(hash) {
|
||||
|
||||
item.finish();
|
||||
|
||||
item.cb.forEach(function(cb) {
|
||||
cb();
|
||||
item.callback.forEach(function(callback) {
|
||||
callback();
|
||||
});
|
||||
|
||||
return item;
|
||||
};
|
||||
|
||||
Pool.prototype.getBlock = function getBlock(hash, cb) {
|
||||
Pool.prototype.getBlock = function getBlock(hash, callback) {
|
||||
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) {
|
||||
cb(null, block);
|
||||
callback(null, block);
|
||||
});
|
||||
};
|
||||
|
||||
@ -1562,28 +1565,28 @@ Pool.prototype.sendBlock = function sendBlock(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 cbs, tx, found, delta;
|
||||
|
||||
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)
|
||||
return cb(new Error('Cannot get tx with full node'));
|
||||
return callback(new Error('Cannot get tx with full node'));
|
||||
|
||||
hash = utils.toHex(hash);
|
||||
|
||||
if (typeof range === 'function') {
|
||||
cb = range;
|
||||
callback = range;
|
||||
range = null;
|
||||
}
|
||||
|
||||
// Do not perform duplicate searches
|
||||
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;
|
||||
|
||||
// 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) {
|
||||
delete self.validate.map[hash];
|
||||
cbs.forEach(function(cb) {
|
||||
cb(err, tx, range);
|
||||
cbs.forEach(function(callback) {
|
||||
callback(err, tx, range);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1880,15 +1883,15 @@ Pool.prototype.isMisbehaving = function isMisbehaving(host) {
|
||||
* LoadRequest
|
||||
*/
|
||||
|
||||
function LoadRequest(pool, peer, type, hash, cb) {
|
||||
function LoadRequest(pool, peer, type, hash, callback) {
|
||||
this.pool = pool;
|
||||
this.peer = peer;
|
||||
this.type = type;
|
||||
this.hash = hash;
|
||||
this.cb = [];
|
||||
this.callback = [];
|
||||
|
||||
if (cb)
|
||||
this.cb.push(cb);
|
||||
if (callback)
|
||||
this.callback.push(callback);
|
||||
|
||||
this._finish = this.finish.bind(this);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user