minor improvements and fixes.

This commit is contained in:
Christopher Jeffrey 2015-12-27 22:56:53 -08:00
parent afcb89f76f
commit 43b0533a18
7 changed files with 16 additions and 9 deletions

View File

@ -307,10 +307,13 @@ Block.prototype.getReward = function getReward() {
if (this._reward)
return this._reward;
base = Block.reward(this.height);
if (this.txs.length === 0 || !this.txs[0].isCoinbase()) {
return this._reward = {
fee: new bn(0),
reward: Block.reward(this.height)
reward: base,
base: base
};
}
@ -319,8 +322,6 @@ Block.prototype.getReward = function getReward() {
return total;
}, new bn(0));
base = Block.reward(this.height);
// If height is not accurate, artificially increase
// the reward era until base is smaller than the reward.
height = 0;
@ -333,7 +334,8 @@ Block.prototype.getReward = function getReward() {
return this._reward = {
fee: fee,
reward: reward
reward: reward,
base: base
};
};
@ -371,6 +373,7 @@ Block.prototype.inspect = function inspect() {
copy.nextBlock = this.nextBlock;
copy.reward = utils.btc(this.reward);
copy.fee = utils.btc(this.fee);
copy.date = new Date((copy.ts || 0) * 1000).toISOString();
return copy;
};

View File

@ -105,7 +105,7 @@ Input.prototype.__defineGetter__('m', function() {
});
Input.prototype.__defineGetter__('n', function() {
return this.data.n || this.data.m;
return this.data.n || this.m;
});
Input.prototype.__defineGetter__('lock', function() {

View File

@ -89,7 +89,7 @@ Output.prototype.__defineGetter__('m', function() {
});
Output.prototype.__defineGetter__('n', function() {
return this.data.n || this.data.m;
return this.data.n || this.m;
});
Output.prototype.__defineGetter__('lock', function() {

View File

@ -569,10 +569,11 @@ Pool.prototype.watch = function watch(id) {
Pool.prototype.unwatch = function unwatch(id) {
var i;
id = utils.toHex(id);
if (!this.bloom.test(id, 'hex'))
return;
id = utils.toHex(id);
if (!this.watchMap[id] || --this.watchMap[id] !== 0)
return;

View File

@ -123,11 +123,12 @@ Framer.prototype.verack = function verack() {
Framer.prototype._inv = function _inv(command, items) {
var res = [];
var off = utils.writeIntv(res, items.length, 0);
var i, hash;
var off, i, hash;
assert(items.length <= 50000);
off = utils.writeIntv(res, items.length, 0);
for (i = 0; i < items.length; i++) {
// Type
off += writeU32(res, constants.inv[items[i].type], off);

View File

@ -914,6 +914,7 @@ TX.prototype.inspect = function inspect() {
copy.fee = utils.btc(this.fee);
copy.height = this.height;
copy.confirmations = this.confirmations;
copy.date = new Date((copy.ts || 0) * 1000).toISOString();
return copy;
};

View File

@ -595,6 +595,7 @@ utils.toBTC = function toBTC(satoshi, strict) {
};
utils.satoshi =
utils.toSatoshi =
utils.fromBTC = function fromBTC(btc, strict) {
var satoshi, parts, hi, lo;