From 5357fd8567bb258e3ed13c6555d98577f4947508 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 7 Jun 2016 11:32:52 -0700 Subject: [PATCH] rename compactblock to avoid confusion. --- lib/bcoin/chain.js | 6 ++-- lib/bcoin/env.js | 4 +-- lib/bcoin/{compactblock.js => memblock.js} | 34 +++++++++++----------- lib/bcoin/peer.js | 2 +- lib/bcoin/protocol/parser.js | 4 +-- 5 files changed, 25 insertions(+), 25 deletions(-) rename lib/bcoin/{compactblock.js => memblock.js} (78%) diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index 1808cc7f..2e3ee63d 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -1333,7 +1333,7 @@ Chain.prototype.isBusy = function isBusy() { /** * Add a block to the chain, perform all necessary verification. - * @param {Block|MerkleBlock|CompactBlock} block + * @param {Block|MerkleBlock|MemBlock} block * @param {Function} callback - Returns [{@link VerifyError}]. */ @@ -1531,7 +1531,7 @@ Chain.prototype.add = function add(block, callback, force) { // fully validated here. They are deserialized, // validated, and emitted. Hopefully the deserialized // blocks get cleaned up by the GC quickly. - if (block.compact) { + if (block.memory) { try { block = block.toBlock(); } catch (e) { @@ -1822,7 +1822,7 @@ Chain.prototype.getEntry = function getEntry(hash, callback) { /** * Get an orphan block. * @param {Hash} hash - * @returns {Block|MerkleBlock|CompactBlock} + * @returns {Block|MerkleBlock|MemBlock} */ Chain.prototype.getOrphan = function getOrphan(hash) { diff --git a/lib/bcoin/env.js b/lib/bcoin/env.js index f13d1e61..bf3412b8 100644 --- a/lib/bcoin/env.js +++ b/lib/bcoin/env.js @@ -79,7 +79,7 @@ if (!utils.isBrowser) * @property {Function} mtx - {@link MTX} constructor. * @property {Function} txdb - {@link TXDB} constructor. * @property {Function} abstractblock - {@link AbstractBlock} constructor. - * @property {Function} compactblock - {@link CompactBlock} constructor. + * @property {Function} memblock - {@link MemBlock} constructor. * @property {Function} block - {@link Block} constructor. * @property {Function} merkleblock - {@link MerkleBlock} constructor. * @property {Function} headers - {@link Headers} constructor. @@ -157,7 +157,7 @@ function Environment(options) { this.mtx = require('./mtx'); this.txdb = require('./txdb'); this.abstractblock = require('./abstractblock'); - this.compactblock = require('./compactblock'); + this.memblock = require('./memblock'); this.block = require('./block'); this.merkleblock = require('./merkleblock'); this.headers = require('./headers'); diff --git a/lib/bcoin/compactblock.js b/lib/bcoin/memblock.js similarity index 78% rename from lib/bcoin/compactblock.js rename to lib/bcoin/memblock.js index 7ae2d28c..b9f4cc59 100644 --- a/lib/bcoin/compactblock.js +++ b/lib/bcoin/memblock.js @@ -1,5 +1,5 @@ /*! - * compactblock.js - compact block object for bcoin + * memblock.js - memblock block object for bcoin * Copyright (c) 2014-2015, Fedor Indutny (MIT License) * Copyright (c) 2014-2016, Christopher Jeffrey (MIT License). * https://github.com/indutny/bcoin @@ -14,7 +14,7 @@ var utils = require('./utils'); * collector's head will explode if there is too much * data on the javascript heap. Blocks can currently * be up to 1mb in size. In the future, they may be - * 2mb, 8mb, or maybe 20mb, who knows? A CompactBlock + * 2mb, 8mb, or maybe 20mb, who knows? A MemBlock * is an optimization in BCoin which defers parsing of * the serialized transactions (the block Buffer) until * the block has passed through the chain queue and @@ -24,7 +24,7 @@ var utils = require('./utils'); * lot of strain off of the garbage collector. Having * 500mb of blocks on the js heap would not be a good * thing. - * @exports CompactBlock + * @exports MemBlock * @constructor * @param {Object} data * @property {Number} version - Block version. Note @@ -38,7 +38,7 @@ var utils = require('./utils'); * @property {Number} nonce * @property {Number} totalTX - Transaction count. * @property {Number} height - Block height (-1 if not present). - * @property {Boolean} compact - Always true. + * @property {Boolean} memory - Always true. * @property {Number} coinbaseHeight - The coinbase height which * was extracted by the parser (the coinbase is the only * transaction we parse ahead of time). @@ -46,37 +46,37 @@ var utils = require('./utils'); * @property {ReversedHash} rhash - Reversed block hash (uint256le). */ -function CompactBlock(data) { - if (!(this instanceof CompactBlock)) - return new CompactBlock(data); +function MemBlock(data) { + if (!(this instanceof MemBlock)) + return new MemBlock(data); bcoin.abstractblock.call(this, data); - this.compact = true; + this.memory = true; this.coinbaseHeight = data.coinbaseHeight; this.raw = data.raw; } -utils.inherits(CompactBlock, bcoin.abstractblock); +utils.inherits(MemBlock, bcoin.abstractblock); /** * Get the full block size. * @returns {Number} */ -CompactBlock.prototype.getSize = function getSize() { +MemBlock.prototype.getSize = function getSize() { return this.raw.length; }; /** * Verify the block headers. - * @alias CompactBlock#verify + * @alias MemBlock#verify * @param {Object?} ret - Return object, may be * set with properties `reason` and `score`. * @returns {Boolean} */ -CompactBlock.prototype._verify = function _verify(ret) { +MemBlock.prototype._verify = function _verify(ret) { return this.verifyHeaders(ret); }; @@ -86,7 +86,7 @@ CompactBlock.prototype._verify = function _verify(ret) { * @returns {Number} height (-1 if not present). */ -CompactBlock.prototype.getCoinbaseHeight = function getCoinbaseHeight() { +MemBlock.prototype.getCoinbaseHeight = function getCoinbaseHeight() { return this.coinbaseHeight; }; @@ -96,19 +96,19 @@ CompactBlock.prototype.getCoinbaseHeight = function getCoinbaseHeight() { * @throws Parse error */ -CompactBlock.prototype.toBlock = function toBlock() { +MemBlock.prototype.toBlock = function toBlock() { var data = bcoin.protocol.parser.parseBlock(this.raw); delete this.raw; return new bcoin.block(data); }; /** - * Test whether an object is a CompactBlock. + * Test whether an object is a MemBlock. * @param {Object} obj * @returns {Boolean} */ -CompactBlock.isCompactBlock = function isCompactBlock(obj) { +MemBlock.isMemBlock = function isMemBlock(obj) { return obj && typeof obj.toBlock === 'function'; }; @@ -116,4 +116,4 @@ CompactBlock.isCompactBlock = function isCompactBlock(obj) { * Expose */ -module.exports = CompactBlock; +module.exports = MemBlock; diff --git a/lib/bcoin/peer.js b/lib/bcoin/peer.js index f86ed610..4f2f288c 100644 --- a/lib/bcoin/peer.js +++ b/lib/bcoin/peer.js @@ -685,7 +685,7 @@ Peer.prototype._onPacket = function onPacket(packet) { case 'filterclear': return this._handleFilterClear(payload); case 'block': - payload = new bcoin.compactblock(payload); + payload = new bcoin.memblock(payload); this.fire(cmd, payload); break; case 'merkleblock': diff --git a/lib/bcoin/protocol/parser.js b/lib/bcoin/protocol/parser.js index dda8d108..9c5db84f 100644 --- a/lib/bcoin/protocol/parser.js +++ b/lib/bcoin/protocol/parser.js @@ -342,7 +342,7 @@ Parser.prototype.parsePayload = function parsePayload(cmd, p) { case 'headers': return Parser.parseHeaders(p); case 'block': - return Parser.parseBlockCompact(p); + return Parser.parseMemBlock(p); case 'tx': return Parser.parseTX(p); case 'reject': @@ -829,7 +829,7 @@ Parser.parseBlock = function parseBlock(p) { * @returns {NakedBlock} */ -Parser.parseBlockCompact = function parseBlockCompact(p) { +Parser.parseMemBlock = function parseMemBlock(p) { var version, prevBlock, merkleRoot; var ts, bits, nonce, totalTX, height; var inCount, input;