This commit is contained in:
Christopher Jeffrey 2016-02-23 00:21:24 -08:00
parent b473ca7d18
commit 68f3ef599d
5 changed files with 7 additions and 13 deletions

View File

@ -127,7 +127,7 @@ Block.verify = function verify(data, subtype) {
};
Block.prototype.render = function render() {
if (this.network && this._raw && this._raw.length > 80)
if (this.network && this._raw)
return this._raw;
return bcoin.protocol.framer.block(this, this.subtype);
};
@ -561,10 +561,7 @@ Block.prototype.toRaw = function toRaw(enc) {
assert(this.subtype === 'block');
if (this.network && this._raw && this._raw.length > 80)
data = this._raw;
else
data = new Buffer(this.render());
data = new Buffer(this.render());
if (enc === 'hex')
data = utils.toHex(data);

View File

@ -231,12 +231,9 @@ Miner.prototype.createBlock = function createBlock(tx) {
// miner succeeded.
new Buffer(this.msg || 'mined by bcoin', 'ascii')
],
seq: 0xffffffff
sequence: 0xffffffff
});
if (bcoin.script.getSize(coinbase.inputs[0].script) > 100)
throw new Error('Coinbase script is too large');
coinbase.addOutput({
address: this.address,
value: new bn(0)
@ -246,7 +243,7 @@ Miner.prototype.createBlock = function createBlock(tx) {
headers = {
version: 4,
prevBlock: this.last.hash,
merkleRoot: utils.toHex(constants.zeroHash.slice()),
merkleRoot: utils.toHex(constants.zeroHash),
ts: ts,
bits: target,
nonce: 0

View File

@ -262,7 +262,7 @@ Framer.prototype._getBlocks = function _getBlocks(cmd, hashes, stop) {
}
if (stop) {
if (typeof hash === 'string')
if (typeof stop === 'string')
stop = new Buffer(stop, 'hex');
len = utils.copy(stop, p, off);
} else {

View File

@ -440,7 +440,7 @@ Parser.prototype.parseCoin = function parseCoin(p, extended) {
spent = utils.readU8(p, off) === 1;
off += 1;
} else {
hash = constants.zeroHash;
hash = new Buffer(constants.zeroHash);
index = 0xffffffff;
spent = false;
}

View File

@ -832,7 +832,7 @@ TX.prototype.signatureHash = function signatureHash(index, s, type) {
// Bitcoind used to return 1 as an error code:
// it ended up being treated like a hash.
if (index >= copy.outputs.length)
return constants.oneHash.slice();
return new Buffer(constants.oneHash);
// Drop all the outputs after the input index.
copy.outputs.length = index + 1;