add rblock and rhash helpers.
This commit is contained in:
parent
52b653083c
commit
68c16b214a
@ -288,6 +288,10 @@ Block.prototype.getNextBlock = function getNextBlock(chain) {
|
||||
return this._nextBlock = next;
|
||||
};
|
||||
|
||||
Block.prototype.__defineGetter__('rblock', function() {
|
||||
return utils.revHex(this.hash('hex'));
|
||||
});
|
||||
|
||||
Block.prototype.toJSON = function toJSON() {
|
||||
return {
|
||||
v: '1',
|
||||
|
||||
@ -607,7 +607,7 @@ Chain.prototype.getHeight = function getHeight(hash) {
|
||||
i = this.index.hashes.indexOf(hash);
|
||||
height = this.index.heights[i];
|
||||
|
||||
if (height === null)
|
||||
if (height == null)
|
||||
return -1;
|
||||
|
||||
return height;
|
||||
|
||||
@ -1164,6 +1164,16 @@ TX.prototype.getConfirmations = function getConfirmations(chain) {
|
||||
return top - height + 1;
|
||||
};
|
||||
|
||||
TX.prototype.__defineGetter__('rblock', function() {
|
||||
return this.block
|
||||
? utils.revHex(this.block)
|
||||
: null;
|
||||
});
|
||||
|
||||
TX.prototype.__defineGetter__('rhash', function() {
|
||||
return utils.revHex(this.hash('hex'));
|
||||
});
|
||||
|
||||
TX.prototype.toJSON = function toJSON() {
|
||||
// Compact representation
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user