minor changes/fixes.

This commit is contained in:
Christopher Jeffrey 2016-02-03 02:09:03 -08:00
parent 3158f57e0f
commit e0ab0ab88d
5 changed files with 22 additions and 20 deletions

View File

@ -1247,7 +1247,7 @@ ChainBlock.fromJSON = function(chain, json) {
ChainBlock.prototype.toRaw = function toRaw() {
var res = new Buffer(BLOCK_SIZE);
utils.writeU32(res, this.version, 0);
utils.write32(res, this.version, 0);
utils.copy(utils.toArray(this.prevBlock, 'hex'), res, 4);
utils.copy(utils.toArray(this.merkleRoot, 'hex'), res, 36);
utils.writeU32(res, this.ts, 68);

View File

@ -45,7 +45,7 @@ function Peer(pool, createConnection, options) {
this.challenge = null;
this.lastPong = 0;
this.banscore = 0;
this.banScore = 0;
this.orphans = 0;
this.orphanTime = 0;

View File

@ -187,7 +187,7 @@ Pool.prototype._init = function _init() {
peer ? peer.host : ''
);
self.emit('fork', [data.expected, data.received]);
self.emit('fork', data.expected, data.received);
if (!peer)
return;
@ -1061,6 +1061,9 @@ Pool.prototype.addWallet = function addWallet(w, defaultTs) {
if (this.loading)
return this.once('load', this.addWallet.bind(this, w, defaultTs));
if (w.loading)
return w.once('load', this.addWallet.bind(this, w, defaultTs));
if (this.wallets.indexOf(w) !== -1)
return false;
@ -1084,7 +1087,6 @@ Pool.prototype.addWallet = function addWallet(w, defaultTs) {
if (!ts)
ts = defaultTs || (utils.now() - 7 * 24 * 3600);
// self.search(false, ts, e);
self.searchWallet(ts);
}
@ -1671,9 +1673,9 @@ Pool.prototype.isOrphaning = function isOrphaning(peer) {
};
Pool.prototype.setMisbehavior = function setMisbehavior(peer, dos) {
peer.banscore += dos;
peer.banScore += dos;
if (peer.banscore >= constants.banScore) {
if (peer.banScore >= constants.banScore) {
this.peers.misbehaving[peer.host] = utils.now();
utils.debug('Ban threshold exceeded for %s', peer.host);
peer.destroy();
@ -1696,7 +1698,7 @@ Pool.prototype.isMisbehaving = function isMisbehaving(host) {
delete this.peers.misbehaving[host];
peer = this.getPeer(host);
if (peer)
peer.banscore = 0;
peer.banScore = 0;
return false;
}
return true;

View File

@ -1587,7 +1587,7 @@ TX.prototype.isStandard = function isStandard() {
for (i = 0; i < this.inputs.length; i++) {
input = this.inputs[i];
if (script.getSize(input.script) > 1650)
if (bcoin.script.getSize(input.script) > 1650)
return false;
if (!bcoin.script.isPushOnly(input.script))

View File

@ -38,8 +38,8 @@ function Wallet(options) {
this._labelMap = {};
this.accountIndex = options.accountIndex || 0;
this.addressIndex = options.addressIndex || 0;
this.changeIndex = options.changeIndex || 0;
this.addressDepth = options.addressDepth || 0;
this.changeDepth = options.changeDepth || 0;
if (!options.addresses)
options.addresses = [];
@ -73,7 +73,7 @@ function Wallet(options) {
this.changeAddress = this.addresses[i];
this.storage = options.storage;
this.loaded = false;
this.loading = true;
this.lastTs = 0;
this.prefix = 'bt/wallet/' + this.getKeyAddress() + '/';
@ -99,7 +99,7 @@ Wallet.prototype._init = function init() {
var prevBalance = null;
if (this.tx._loaded) {
this.loaded = true;
this.loading = false;
return;
}
@ -123,7 +123,7 @@ Wallet.prototype._init = function init() {
});
this.tx.once('load', function(ts) {
self.loaded = true;
self.loading = false;
self.lastTs = ts;
self.emit('load', ts);
});
@ -179,7 +179,7 @@ Wallet.prototype.createChangeAddress = function createChangeAddress(options) {
if (this.master) {
options.priv =
this.master.key.hd.deriveChange(this.accountIndex, this.changeIndex++);
this.master.key.hd.deriveChange(this.accountIndex, this.changeDepth++);
}
return this.addAddress(options);
@ -191,7 +191,7 @@ Wallet.prototype.createNewAddress = function createNewAddress(options) {
if (this.master) {
options.priv =
this.master.key.hd.deriveAddress(this.accountIndex, this.addressIndex++);
this.master.key.hd.deriveAddress(this.accountIndex, this.addressDepth++);
}
return this.addAddress(options);
@ -546,8 +546,8 @@ Wallet.prototype.toJSON = function toJSON(encrypt) {
name: 'wallet',
network: network.type,
accountIndex: this.accountIndex,
addressIndex: this.addressIndex,
changeIndex: this.changeIndex,
addressDepth: this.addressDepth,
changeDepth: this.changeDepth,
master: this.master ? this.master.toJSON(encrypt) : null,
addresses: this.addresses.filter(function(address) {
if (!address.key.hd)
@ -576,8 +576,8 @@ Wallet.fromJSON = function fromJSON(json, decrypt) {
w = new Wallet({
accountIndex: json.accountIndex,
addressIndex: json.addressIndex,
changeIndex: json.changeIndex,
addressDepth: json.addressDepth,
changeDepth: json.changeDepth,
master: json.master
? bcoin.address.fromJSON(json.master, decrypt)
: null,
@ -591,7 +591,7 @@ Wallet.fromJSON = function fromJSON(json, decrypt) {
// Make sure we have all the change
// addresses (we don't save them).
if (w.master) {
for (i = 0; i < w.changeIndex; i++) {
for (i = 0; i < w.changeDepth; i++) {
w.addAddress({
change: true,
priv: w.master.key.hd.deriveChange(w.accountIndex, i)