refactor: misc.
This commit is contained in:
parent
f2c6bced5a
commit
a467b4e475
@ -148,7 +148,6 @@ if (utils.isBrowser)
|
|||||||
* @param {String?} options.location - Database location
|
* @param {String?} options.location - Database location
|
||||||
* @param {String?} options.db - Database backend name
|
* @param {String?} options.db - Database backend name
|
||||||
* @property {Boolean} prune
|
* @property {Boolean} prune
|
||||||
* @property {Boolean} loaded
|
|
||||||
* @property {Number} keepBlocks
|
* @property {Number} keepBlocks
|
||||||
* @emits ChainDB#open
|
* @emits ChainDB#open
|
||||||
* @emits ChainDB#error
|
* @emits ChainDB#error
|
||||||
@ -181,8 +180,6 @@ function ChainDB(chain) {
|
|||||||
this.pending = null;
|
this.pending = null;
|
||||||
this.current = null;
|
this.current = null;
|
||||||
|
|
||||||
this.loaded = false;
|
|
||||||
|
|
||||||
// We want at least 1 retarget interval cached
|
// We want at least 1 retarget interval cached
|
||||||
// for retargetting, but we need at least two
|
// for retargetting, but we need at least two
|
||||||
// cached for optimal versionbits state checks.
|
// cached for optimal versionbits state checks.
|
||||||
@ -1368,12 +1365,11 @@ ChainDB.prototype.getFullTX = co(function* getFullTX(hash) {
|
|||||||
|
|
||||||
ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) {
|
ChainDB.prototype.getFullBlock = co(function* getFullBlock(hash) {
|
||||||
var block = yield this.getBlock(hash);
|
var block = yield this.getBlock(hash);
|
||||||
var view;
|
|
||||||
|
|
||||||
if (!block)
|
if (!block)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
view = yield this.getUndoView(block);
|
yield this.getUndoView(block);
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -366,7 +366,7 @@ Peer.prototype._bip150 = co(function* _bip150() {
|
|||||||
|
|
||||||
if (this.bip150.outbound) {
|
if (this.bip150.outbound) {
|
||||||
if (!this.bip150.peerIdentity)
|
if (!this.bip150.peerIdentity)
|
||||||
return this.error('No known identity for peer.');
|
throw new Error('No known identity for peer.');
|
||||||
this.send(this.bip150.toChallenge());
|
this.send(this.bip150.toChallenge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2315,9 +2315,8 @@ Peer.prototype.sendReject = function sendReject(code, reason, obj) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Peer.prototype.sendCompact = function sendCompact() {
|
Peer.prototype.sendCompact = function sendCompact() {
|
||||||
var cmpct = new packets.SendCmpctPacket(0, 1);
|
|
||||||
this.logger.info('Initializing compact blocks (%s).', this.hostname);
|
this.logger.info('Initializing compact blocks (%s).', this.hostname);
|
||||||
this.send(cmpct);
|
this.send(new packets.SendCmpctPacket(0, 1));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2496,7 +2496,7 @@ BroadcastItem.prototype.start = function start() {
|
|||||||
BroadcastItem.prototype.refresh = function refresh() {
|
BroadcastItem.prototype.refresh = function refresh() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (this.timeout) {
|
if (this.timeout != null) {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = null;
|
this.timeout = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1025,9 +1025,8 @@ WalletDB.prototype.getPendingKeys = function getPendingKeys() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
WalletDB.prototype.resend = co(function* resend() {
|
WalletDB.prototype.resend = co(function* resend() {
|
||||||
var i, keys, key, data, tx;
|
var keys = yield this.getPendingKeys();
|
||||||
|
var i, key, data, tx;
|
||||||
keys = yield this.getPendingKeys();
|
|
||||||
|
|
||||||
if (keys.length > 0)
|
if (keys.length > 0)
|
||||||
this.logger.info('Rebroadcasting %d transactions.', keys.length);
|
this.logger.info('Rebroadcasting %d transactions.', keys.length);
|
||||||
@ -1094,7 +1093,7 @@ WalletDB.prototype.getPathInfo = co(function* getPathInfo(wallet, tx) {
|
|||||||
|
|
||||||
WalletDB.prototype.getTable = co(function* getTable(hashes) {
|
WalletDB.prototype.getTable = co(function* getTable(hashes) {
|
||||||
var table = {};
|
var table = {};
|
||||||
var count = 0;
|
var match = false;
|
||||||
var i, j, keys, values, hash, paths;
|
var i, j, keys, values, hash, paths;
|
||||||
|
|
||||||
for (i = 0; i < hashes.length; i++) {
|
for (i = 0; i < hashes.length; i++) {
|
||||||
@ -1115,10 +1114,10 @@ WalletDB.prototype.getTable = co(function* getTable(hashes) {
|
|||||||
|
|
||||||
assert(!table[hash]);
|
assert(!table[hash]);
|
||||||
table[hash] = values;
|
table[hash] = values;
|
||||||
count += values.length;
|
match = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count === 0)
|
if (!match)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user