fcoin/lib/bcoin/compactblock.js
2016-03-05 02:18:39 -08:00

52 lines
1.1 KiB
JavaScript

/**
* compactblock.js - compact block object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
* https://github.com/indutny/bcoin
*/
var bcoin = require('../bcoin');
var bn = require('bn.js');
var utils = bcoin.utils;
var assert = utils.assert;
var constants = bcoin.protocol.constants;
var network = bcoin.protocol.network;
/**
* CompactBlock
*/
function CompactBlock(data) {
var self = this;
if (!(this instanceof CompactBlock))
return new CompactBlock(data);
bcoin.abstractblock.call(this, data);
this.type = 'compactblock';
this.coinbaseHeight = data.coinbaseHeight;
}
utils.inherits(CompactBlock, bcoin.abstractblock);
CompactBlock.prototype._verify = function _verify() {
return this.verifyHeaders();
};
CompactBlock.prototype.getCoinbaseHeight = function getCoinbaseHeight() {
return this.coinbaseHeight;
};
CompactBlock.prototype.toBlock = function toBlock() {
var block = new bcoin.block(bcoin.protocol.parser.parseBlock(this._raw));
if (this.valid != null)
block.valid = this.valid;
return block;
};
/**
* Expose
*/
module.exports = CompactBlock;