minor.
This commit is contained in:
parent
d89bd13f09
commit
0b8101b756
@ -2531,5 +2531,37 @@ Chain.prototype.checkLocks = function checkLocks(tx, flags, entry, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the difficulty.
|
||||
* @param {ChainBlock} entry
|
||||
* @returns {Number} Difficulty.
|
||||
*/
|
||||
|
||||
Chain.prototype.getDifficulty = function getDifficulty(entry) {
|
||||
var shift, diff;
|
||||
|
||||
if (!entry) {
|
||||
if (!this.tip)
|
||||
return 1.0;
|
||||
entry = this.tip;
|
||||
}
|
||||
|
||||
shift = (entry.bits >>> 24) & 0xff;
|
||||
diff = 0x0000ffff / (entry.bits & 0x00ffffff);
|
||||
|
||||
while (shift < 29) {
|
||||
diff *= 256.0;
|
||||
shift++;
|
||||
}
|
||||
|
||||
while (shift > 29) {
|
||||
diff /= 256.0;
|
||||
shift--;
|
||||
}
|
||||
|
||||
return diff;
|
||||
};
|
||||
|
||||
return Chain;
|
||||
};
|
||||
|
||||
@ -767,3 +767,11 @@ exports.confidence = {
|
||||
|
||||
UNKNOWN: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* The name of our currency.
|
||||
* @const {String}
|
||||
* @default
|
||||
*/
|
||||
|
||||
exports.CURRENCY_UNIT = 'BTC';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user